Re: XML Schema validation error
- From: aparker <aparker@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 17 Feb 2009 08:36:07 -0800
Hi Martin
Thanks for your response. I am validating this xml to this schema using a
validating XML reader in dotnet code. I guess my problem id lack of
experience here, But I cannot change the xml as this is output from a program
I don't control, so I need to fix the schema so that it validates. From you r
response I need to add a schema definition for the datasets element?
I appreciate your help,
Andy
"Martin Honnen" wrote:
aparker wrote:.
I am fairly new at XML validation and am having real trouble figuring out
why I can’t validate the following. I have a schema file that I get from
adobe describing their ‘xdp’ xml format. I then validate an xdp file
generated by an adobe reader product. I try to validate this file against the
schema but I get a validation error. Does anyone have an idea why I am
getting this? I have spent a considerable amount of time on this and am
getting nowhere.
The error I am getting is.....
"The 'http://ns.adobe.com/xdp/:xdp' element is not declared. "
How exactly are you trying to validate? With Visual Studio? With .NET code?
Here is the schema…
<?xml version="1.0" encoding="utf-8" ?>
<xs:schema id="xdpCollection" targetNamespace="http://ns.adobe.com/xdp/"
xmlns:mstns="http://ns.adobe.com/xdp/" xmlns="http://ns.adobe.com/xdp/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
attributeFormDefault="qualified" elementFormDefault="qualified">
<xs:element name="xdp" msdata:Prefix="xdp">
<xs:complexType>
<xs:sequence>
<xs:element name="config" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="0" />
<xs:element name="connectionSet" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="1" />
<xs:element name="datasets" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="2" />
<xs:element name="localeSet" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="3" />
<xs:element name="pdf" form="unqualified" type="xs:string" minOccurs="0"
msdata:Ordinal="4" />
<xs:element name="sourceSet" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="5" />
<xs:element name="style***" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="6" />
<xs:element name="template" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="7" />
<xs:element name="xdc" form="unqualified" type="xs:string" minOccurs="0"
msdata:Ordinal="8" />
<xs:element name="xfdf" form="unqualified" type="xs:string" minOccurs="0"
msdata:Ordinal="9" />
<xs:element name="xmpmeta" form="unqualified" type="xs:string"
minOccurs="0" msdata:Ordinal="10" />
</xs:sequence>
<xs:attribute name="uuid" form="unqualified" type="xs:string" />
<xs:attribute name="timeStamp" form="unqualified" type="xs:string" />
</xs:complexType>
</xs:element>
<xs:element name="xdpCollection" msdata:IsDataSet="true"
msdata:UseCurrentLocale="true" msdata:Prefix="xdp">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="xdp" />
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
Here is my xml file
<?xml version="1.0" encoding="UTF-8" ?>
<?xfa generator="XFA2_4" APIVersion="2.8.8118.0"?>
<xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"
timeStamp="2009-01-27T19:15:06Z" uuid="3ff953dd-58c6-4fc2-8359-21e051961b01">
<xfa:datasets xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/">
When I pull both of your files in Visual Studio 2008 then it complains
The element 'xdp' in namespace 'http://ns.adobe.com/xdp/' has invalid
child element 'datasets' in namespace
'http://www.xfa.org/schema/xfa-data/1.0/'. List of possible elements
expected: 'config, connectionSet, datasets, localeSet, pdf, sourceSet,
style***, template, xdc, xfdf, xmpmeta'.
and that is correct, you have only one schema, it defines an element
named 'xdp' in the namespace 'http://ns.adobe.com/xdp/' and allows
elements named 'config', 'connectionSet', 'datasets' in no namespace
while your XML above has an element named 'datasets' in the namespace
'http://www.xfa.org/schema/xfa-data/1.0/'.
So your XML instance is not valid against the schema you have.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
- Follow-Ups:
- Re: XML Schema validation error
- From: Martin Honnen
- Re: XML Schema validation error
- References:
- XML Schema validation error
- From: aparker
- Re: XML Schema validation error
- From: Martin Honnen
- XML Schema validation error
- Prev by Date: OpenXML Changing Text in word document
- Next by Date: Re: XML Schema validation error
- Previous by thread: Re: XML Schema validation error
- Next by thread: Re: XML Schema validation error
- Index(es):
Loading