xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
[XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute
- From: "Brian Uri!" <brian AT urizone.net>
- To: xom-interest AT lists.ibiblio.org
- Subject: [XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute
- Date: Sat, 24 Sep 2011 17:07:47 -0400
Hello,
I seem to be hitting a bug, but I can't determine whether it's a bug in XOM
or just schemas which could be better written. I've pruned down the code and
schemas to the bare bits needed to reproduce the issue below.
I have a schema which defines an element and has a fixed optional attribute
from a third-party schema (XLink 1.1):
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="urn:buri:bugtest" xmlns:buri="urn:buri:bugtest"
xmlns:xlink="http://www.w3.org/1999/xlink"
targetNamespace="urn:buri:bugtest" elementFormDefault="qualified"
attributeFormDefault="qualified">
<xs:import namespace="http://www.w3.org/1999/xlink"
schemaLocation="XLink.xsd"/>
<xs:element name="revision" type="RevisionType" />
<xs:complexType name="RevisionType">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute ref="xlink:type" fixed="resource"
use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
The XLink 1.1 schema provides the definition for the xlink:type attribute:
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xlink="http://www.w3.org/1999/xlink"
targetNamespace="http://www.w3.org/1999/xlink">
<xs:attribute name="type" type="xlink:typeType" />
<xs:simpleType name="typeType">
<xs:restriction base="xs:token">
<xs:enumeration value="simple"/>
<xs:enumeration value="extended"/>
<xs:enumeration value="title"/>
<xs:enumeration value="resource"/>
<xs:enumeration value="locator"/>
<xs:enumeration value="arc"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>
When I try to build a Document with the instance below in a file, everything
works fine:
<?xml version='1.0' encoding='UTF-8'?>
<buri:revision xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:buri="urn:buri:bugtest" xlink:type="resource" />
However, if I remove the attribute from the instance, like this:
<?xml version='1.0' encoding='UTF-8'?>
<buri:revision xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:buri="urn:buri:bugtest" />
I get this error from XOM:
nu.xom.ParsingException: Unprefixed attribute type cannot be in default
namespace http://www.w3.org/1999/xlink
at nu.xom.Builder.build(Unknown Source)
[...]
Caused by: nu.xom.NamespaceConflictException: Unprefixed attribute type
cannot be in default namespace http://www.w3.org/1999/xlink
at nu.xom.Attribute._setNamespace(Unknown Source)
at nu.xom.Attribute.<init>(Unknown Source)
at nu.xom.NodeFactory.makeAttribute(Unknown Source)
If I understand it correctly, a fixed optional attribute need not exist in
an instance, but must have the fixed value if it does, so an instance
without it should still be valid. Since the 2nd instance doesn't even
mention "type", I'm not sure why XOM would be trying to build a type
attribute at all.
The environment details:
xom 1.2.6
xercesImpl 2.9.1
xml-apis 1.3.04
XMLReader: org.apache.xerces.parsers.SAXParser
http://xml.org/sax/features/validation=true
http://apache.org/xml/features/validation/schema=true
http://apache.org/xml/properties/schema/external-schemaLocationpoints
at the schema file
Test Code:
Builder builder = new Builder(xmlReader, true);
builder.build(new FileReader(new File(theInstance)));
Any insights would be appreciated. I'll be glad to provide more details if I
pruned too much!
Thanks!
BU
-
[XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute,
Brian Uri!, 09/24/2011
-
Re: [XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute,
Michael Kay, 09/25/2011
- Re: [XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute, Brian Uri!, 09/26/2011
- Re: [XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute, Elliotte Rusty Harold, 09/27/2011
-
Re: [XOM-interest] Possible Bug: XOM Builder chokes on fixed optional attribute,
Michael Kay, 09/25/2011
Archive powered by MHonArc 2.6.24.