[xsde-users] RE: Why xml_schema::schema exception is thrown when
the xml document is not well formed
Jiang, Bin (Bin)
binjiang at alcatel-lucent.com
Mon Oct 29 12:59:19 EDT 2007
Hi Boris,
Thank you for the explanation!
Please see my other two questions below.
Thanks,
Jiang Bin (Bin)
GLMS Developer
Alcatel-Lucent
> -----Original Message-----
> From: Boris Kolpackov [mailto:boris at codesynthesis.com]
> Sent: 2007年10月29日 18:06
> To: Jiang, Bin (Bin)
> Cc: xsde-users at codesynthesis.com
> Subject: Re: Why xml_schema::schema exception is thrown when the xml
> document is not well formed
>
> Hi Bin,
>
> Jiang, Bin (Bin) <binjiang at alcatel-lucent.com> writes:
>
> > I found in some cases, xml_schema::schema will be thrown when the
> > xml document is not well-formed. Take the example library in the
> > xsde release 1.1.0 as an example:
> >
> > <lib:catalog xmlns:lib="http://www.codesynthesis.com/library"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> > xsi:schemaLocation="http://www.codesynthesis.com/library
> library.xsd">
> >
> > book id="MM" available="false" >
> > <isbn>0679760806</isbn>
> > <title>The Master and Margarita</title>
> > <genre>fiction1</genre>
> > ...
> > </lib:catalog>
>
> Actually, this XML is perfectly well-formed. By removing '<' from
> the book tag, you made it to appear as just a text fragment. Note
> that you don't have to escape '>' in the element content.
>
> > If I remove the "<" of book, the parser would say:
> > schema error: line[15] column[34] unexpected characters encountered
>
> Which is correct. The catalog type specifies that its content should
> be a sequence of book elements. As a result, when parser encounters
> text, it reports it as a validation error.
[Jiang, Bin (Bin)]
In this case, why the column number is not the beginning of the line, but is 34, the end of the line?
When the characters would be ignored by the parser?
I add a type like below to the xsd:
<xsd:complexType name="identityType">
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:choice maxOccurs="unbounded">
<xsd:element name="one" type="xsd:string"/>
<xsd:element name="two" type="xsd:string" minOccurs="0"/>
</xsd:choice>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
And find characters inside "identityType" element would be ignored, is this because the "identityType" type is derived from "xsd:anyType"?
>
> I guess this example shows how far a well-formed XML can be from what
> an application expects and why it is generally a good idea to validate
> the documents against the vocabulary schema :-).
>
> Boris
More information about the xsde-users
mailing list