0

I'm extracting some xml from an XFA static form. Here is a sample:

<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
<xfa:data>
<frmMain>
<InspectionDate>19/02/2012</InspectionDate>
<ENID>111114567</ENID>
<EmployeeNumber>1234</EmployeeNumber>
<GroundType>
   <value>Tarmac</value>
   <value>Concrete</value>
</GroundType>
<Width>800</Width>
<Height>900</Height>
<OtherDetails>Corssing of x road and y street</OtherDetails>
</frmMain>
</xfa:data>
</xfa:datasets>

I use Windows SDK 7.0 utility Xsd.exe to generate a schema so I can validate that XML against Here it is:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="datasets" targetNamespace="http://www.xfa.org/schema/xfa-data/1.0/" xmlns:mstns="http://www.xfa.org/schema/xfa-data/1.0/" xmlns="http://www.xfa.org/schema/xfa-data/1.0/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
  <xs:attribute name="dataNode" msdata:Prefix="xfa" type="xs:string" />
  <xs:element name="datasets" msdata:IsDataSet="true" msdata:Locale="en-US" msdata:Prefix="xfa">
    <xs:complexType>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
        <xs:element name="data" msdata:Prefix="xfa">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="frmMain" form="unqualified">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element name="InspectionDate" form="unqualified" type="xs:string" minOccurs="0" />
                    <xs:element name="ENID" form="unqualified" type="xs:string" minOccurs="0" />
                    <xs:element name="EmployeeNumber" form="unqualified" type="xs:string" minOccurs="0" />
                    <xs:element name="Width" form="unqualified" type="xs:string" minOccurs="0" />
                    <xs:element name="Height" form="unqualified" type="xs:string" minOccurs="0" />
                    <xs:element name="OtherDetails" form="unqualified" type="xs:string" minOccurs="0" />
                    <xs:element name="GroundType" form="unqualified" minOccurs="0" maxOccurs="unbounded">
                      <xs:complexType>
                        <xs:attribute ref="mstns:dataNode" />
                      </xs:complexType>
                    </xs:element>
                  </xs:sequence>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

I use XmlReaderSettings with a XmlReader to read and validate the Xml against the Xsd. Everything is ok as long as I do not have a complex type. But in this case I have.

What can be done?

And the Error I'm getting is:

The element 'GroundType' cannot contain child element 'value' because the parent element's content model is empty.

2
  • Your question is not clear; what is it that it is not OK, what particular error or unexpected behaviour do you see? Commented Feb 19, 2012 at 18:12
  • I have just added the error, thanks for pointing this out Commented Feb 19, 2012 at 18:15

1 Answer 1

1

Your GroundType definition should look like this:

<xs:element name="GroundType" form="unqualified" minOccurs="0" maxOccurs="unbounded">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="value" form="unqualified" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute ref="mstns:dataNode"/>
    </xs:complexType>
</xs:element>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it's all working, it's a shame that Xsd.exe does not do that by default!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.