|
|
|
||
|
Let's just clear the air up front: I like XML Schema. It's convient. It's solves about 90% of all XML validation concerns. It's concise. I have been doing work lately that leverages the validation provided by XSD by supplimenting it with JavaScript and Java. The problem with XSD is that it's not just simple XML. Sure, it's written in XML, but that's not the point. You can't just rip through an XSD with XPath an extract out the information that you want. This becomes obvious when you think about the structure that XSD represents: there's inheritance and references and all kinds of things that go "Bump" in the night. So the primary way that you can get at the guts behind what XSD is providing is via the Post-Schema-Validation Infoset (PSVI). But there's a problem: it appears that there is no way to access non-native (i.e. non- Problem solved I have been banging my head looking for a way to access non-native attributes of an XSD via PSVI. The problem I kept hitting was that the XSD API defines a seemingly limited I started looking for alternative techniques. I found some interesting information regarding // the content of the annotation node, including all children, along // with any non-schema attributes from its parent private String fData = null; Well that certainly does not match the PSVI description of "A text representation of the annotation". The key is the "along with any non-schema attributes from its parent". If your XSD looks like:
<xsd:element name="something" myNS:name="Something">
<xsd:annotation>
<xsd:appinfo>Stuff</xsd:appinfo>
<xsd:annotation>
...
</xsd:element>
then <xsd:annotation myNS:name="Something" ... > <xsd:appinfo>Stuff</xsd:appinfo> <xsd:annotation> No, really. Now those of you that are careful readers are likely sitting there wondering how this is even possible since it's inconsistent. You're wondering what happens when your XSD looks like:
<xsd:element name="something" myNS:name="Something">
<xsd:annotation myNS:name="Something else">
<xsd:appinfo>Stuff</xsd:appinfo>
<xsd:annotation>
...
</xsd:element>
Well, I'm sure you've already guessed the answer: <xsd:annotation myNS:name="Something else" ... > <xsd:appinfo>Stuff</xsd:appinfo> <xsd:annotation> Yup, the attribute from the Why doesn't This is continued in More on XSD, PSVI and non-native attributes. |
| Comments | ||||
|
| Post a comment |
|
|
Unless otherwise expressly stated, all original material of whatever nature created by Rob Grzywinski and included in this weblog and any related pages, including the weblog's archives, is licensed under a Creative Commons License. |