|
|
|
||
|
There are a number of problems with updating XML documents in an XML store. The primary problem is that XQuery 1.0 does not have a facility for updating documents. The XQuery Update Facility Requirements exists but it clearly states "the WG does not intend to produce a Recommendation from this Working Draft" which leaves me with a big fat question mark over my head. This has caused each XML DB vendor to provide their own update mechanism. And this leads to the topic of this post: BDBXML is a decent XML DB but it's somewhat rough around the edges. When updating documents it is common to get the following error: Cannot perform a modification on an XmlValue that isn't either Node or Document type, errcode = INVALID_VALUE To make a long story short, you cannot specify a |
|
||
|
If you have been following along with the trials and tribulations of XSD, PSVI and non-native attributes then you have been left with wondering about case where you have a non-native attribute and no
<xsd:element name="something" myNS:name="Something" ...>
<xsd:simpleType>
..
</xsd:simpleType>
</xsd:element>
Since there is no So we're done, right? Well, no. The page from which the "generate synthetic annotations" is taken is actually for the SAX parser which is not what we use. A quick search of the intersection between To round this out, the synthetic annotation appears as: <xsd:annotation myNS:name="Something" ...> <xsd:documentation>SYNTHETIC_ANNOTATION</xsd:documentation> </xsd:annotation> and the setup code to get an
System.setProperty(DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMXSImplementationSourceImpl");
final DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();
final XSImplementation xsImpl =
(XSImplementation)registry.getDOMImplementation("XS-Loader");
final XSLoader schemaLoader =
xsImpl.createXSLoader(null/*all XML Schema Versions*/);
// NOTE: synthetic annotation nodes MUST be created for non-native
// attributes to be parsed and added to the XSAnnotation object
// (for cases where there is no
|
|
||
|
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. |
|
||
|
I am using Xerces to parse an XML Schema annotation. I stumbled across two intesting situations when dealing with Xerces PSVI:
As a side note to the |
|
|
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. |