woodstox icon indicating copy to clipboard operation
woodstox copied to clipboard

Invalid attribute rejection when element is nillable

Open gkryl opened this issue 6 years ago • 2 comments

XSD:

<?xml version="1.0" encoding="utf-8"?>
<xsd:schema xmlns="http://www.openuri.org/mySchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.openuri.org/mySchema" version="2.0">
	<xsd:element name="purchaseOrder" type="PurchaseOrderType"/>
	<xsd:element name="comment" type="comment_type"/>
	<xsd:complexType name="comment_type">
		<xsd:choice>
			<xsd:element name="annotation" type="xsd:string"/>
			<xsd:element name="note" type="xsd:string"/>
		</xsd:choice>
		<xsd:attribute name="country" type="xsd:string"/>
	</xsd:complexType>
	<xsd:complexType name="PurchaseOrderType">
		<xsd:sequence>
		    <xsd:element name="comment" type="comment_type" nillable="true"/>
		</xsd:sequence>
		<xsd:attribute name="orderDate" type="xsd:date"/>
	</xsd:complexType>
</xsd:schema>

XML: I have to attach my xml file as txt (it is small file, 247 bytes long). This view does not show element when it has attribute xsi:nil="true".

instance.txt

<?xml version="1.0" encoding="UTF-8"?>
<data:purchaseOrder orderDate="2006-10-30" xmlns:data="http://www.openuri.org/mySchema"     
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <comment country="US" xsi:nil="true"/>
</data:purchaseOrder>

Problem:

com.ctc.wstx.exc.WstxValidationException: unexpected attribute "country"

Java's default XSD validator does not report any problems with attribute.

gkryl avatar Nov 28 '17 08:11 gkryl

I have the same issue.

Is it possible that the problem is on the MSV side?

it should only accept empty tag without any attribute. see XSAcceptor.java

LucCappellaro avatar Dec 19 '17 16:12 LucCappellaro

All validation wrt XML Schema is done indeed by MSV; however, Woodstox parser core will need to feed the content so it is also possible that Woodstox might not be passing information correctly. So I don't know off-hand which one might be at fault here.

cowtowncoder avatar Dec 19 '17 19:12 cowtowncoder