Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid attribute rejection when element is nillable #39

Open
gkryl opened this issue Nov 28, 2017 · 2 comments
Open

Invalid attribute rejection when element is nillable #39

gkryl opened this issue Nov 28, 2017 · 2 comments

Comments

@gkryl
Copy link

gkryl commented Nov 28, 2017

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.

@LucCappellaro
Copy link

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

@cowtowncoder
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants