Schema aware parsing bug
Thomas Scheffler <[email protected]> Mon, 5 Oct 2015 15:31:57 +0200
| Newsgroups | gmane.comp.java.jdom.general |
|---|---|
| Organization | Friedrich-Schiller-Universität Jena |
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------010307070903020108070807
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
I try to parse a document schema aware. There is an attribute defined as
fixed="yes". Even if the attribute is not present in the source, it will
be present in the JDOM Element. This should be the behavior of
default="yes" if the attribute is not present.
Semantically the fixed='yes' means the default is 'no' if the attribute
is not present.
This has currently a huge impact we have @invalid='yes' fixed by a 3rd
party schema.
I use Oracle JAVA 1.8.0_51 and put a simple test to show the error in
the attachment. Hope that it can be fixed soon...
regards,
Thomas
--------------010307070903020108070807
Content-Type: text/x-java;
name="SchemaBug.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="SchemaBug.java"
import java.io.IOException;
import org.jdom2.Document;
import org.jdom2.JDOMException;
import org.jdom2.input.SAXBuilder;
import org.jdom2.input.sax.XMLReaders;
import org.jdom2.output.XMLOutputter;
public class SchemaBug {
public static void main(String...arg) throws JDOMException, IOException{
SAXBuilder builder=new SAXBuilder(XMLReaders.XSDVALIDATING);
Document document = builder.build("schemabug.xml");
XMLOutputter xout=new XMLOutputter();
xout.output(document, System.out);
}
}
--------------010307070903020108070807
Content-Type: text/xml;
name="schemabug.xml"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="schemabug.xml"
<?xml version="1.0" encoding="UTF-8"?>
<test
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="schemabug.xsd"
/>
--------------010307070903020108070807
Content-Type: text/xml; x-mac-type="0"; x-mac-creator="0";
name="schemabug.xsd"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="schemabug.xsd"
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="test" type="testDefinition" />
<xs:complexType name="testDefinition">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="optional" default="yes" type="xs:string" />
<xs:attribute name="fixed" fixed="yes" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>
--------------010307070903020108070807
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
--------------010307070903020108070807--