Is it correct to use own tag instead of <rdf:Description/> for restribing some resource?
For example, consider the following example
<?xml version="1.0" ?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description rdf:about="http://en.wikipedia.org/wiki/Tony_Benn">
<dc:title>Tony Benn</dc:title>
<dc:publisher>Wikipedia</dc:publisher>
</rdf:Description>
</rdf:RDF>
here we describe resource http://en.wikipedia.org/wiki/Tony_Benn. We know that he is a Person. It is correct/possible to use own tag instead of< rdf:Description/> ? For example, like this:
<?xml version="1.0" ?>
<rdf:RDF
xm开发者_如何学Pythonlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:z="http://www.zebooka.com/">
<z:Person rdf:about="http://en.wikipedia.org/wiki/Tony_Benn">
<dc:title>Tony Benn</dc:title>
<dc:publisher>Wikipedia</dc:publisher>
</z:Person>
</rdf:RDF>
<z:Person
xmlns:z="http://www.zebooka.com/"
rdf:about="http://en.wikipedia.org/wiki/Tony_Benn" />
is the same, as
<rdf:Description rdf:about="http://en.wikipedia.org/wiki/Tony_Benn">
<rdf:type rdf:resource="http://www.zebooka.com/Person" />
</rdf:Description>
Just make sure http://www.zebooka.com/Person
and its from type rdfs:Class
.
I will answer your question about changing the name of the element, or at least the implications, later. However I would like to point out the description element is describing a document, not that person. I would add a <dc:subject>person</dc:person> element to get the meta info you are looking for that fits the schemas already in use. The subject of the document is a person or the name of that person and the dc namespace defines a subject element. That is my suggested solution for what I can gleam is your use case from your question.
Otherwise, here is a bit more on where to go from here if that solution isn’t viable for you. First you will need to check the scheme defined by the rdf namespace in your example. If the RDF element includes an any element definition that allows any namespace it is possible. There may be other more advanced scheme concepts as well that allow the extension you want, such as description allowing substitution groups. There are examples to do both on this site, use the search.
It is really only viable if you can extend via substitution group if interoperability is concerned. Using a new element without a substitution group seems straight forward. However, if you are looking to create and transfer a document through a compliant implementation the parser is not going to treat that data the same because it won't know the semantic meaning of your element. If you are writing the code for the end points processing the XML you can do whatever you want and you don't need to validate the document or validate it to your own likening. This will require much more work though than honoring the schema for these types.
If you change an element name to a defined element in your schema (without substitution groups) your data isn't going to be interoperable with outside sources. At best the outside vendors will drop all the data in your custom element and at worst it won't read or process any of the data at all. It appears that the element description may accept any additional element (I can't verify because the URL for the schema is down right now) so I would suggest defining your own subelement for description such as type which can contain the value person if you need this information if your goal is to use your own defined element. That way exiting implementations may simply ignore that element if it doesn't understand it but at the same time it won't lose all the other information.
If you are worried about how the data looks on the presentation layer I suggest you transform the data at that point with an xslt transform or whatever is most covenant for your view. There isn't a real need to change the data model.
精彩评论