XSD: Any valid XML in one node - different parser results

M

mkremser

Hi NG!

In a XSD, we (try to) specify that a node ("BsqCallInfo") has two
attributes and can have any nodes as its children:

<xsd:element name="BsqCallInfo">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:any processContents="lax"/>
</xsd:choice>
<xsd:attribute name="Name" type="xsd:string" />
<xsd:attribute name="Description" type="xsd:string" />
</xsd:complexType>
</xsd:element>

Now we have the problem that different parsers handle it differently
and we do not have a clue, which one behaves correctly.

Some parsers claim that

<BsqCallInfo>
<SomeThing></SomeThing>
</BsqCallInfo>

is wrong because "SomeThing" is not part of the schema, others accept
it.

So, what is right, what is wrong?

Best regards,

Michael
 
M

Martin Honnen

In a XSD, we (try to) specify that a node ("BsqCallInfo") has two
attributes and can have any nodes as its children:

<xsd:element name="BsqCallInfo">
<xsd:complexType>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:any processContents="lax"/>
</xsd:choice>
<xsd:attribute name="Name" type="xsd:string" />
<xsd:attribute name="Description" type="xsd:string" />
</xsd:complexType>
</xsd:element>

Now we have the problem that different parsers handle it differently
and we do not have a clue, which one behaves correctly.

Some parsers claim that

<BsqCallInfo>
<SomeThing></SomeThing>
</BsqCallInfo>

is wrong because "SomeThing" is not part of the schema, others accept
it.

Which parsers have you tried, which say the snippet is valid, which say
it is not?
 
P

Priscilla Walmsley

Hi,

It is valid for SomeThing to appear there, even if it is not declared.

When you specify processContents="lax", it means that it looks for
declarations for the elements like SomeThing but if it doesn't find them
it doesn't raise an error. (If it does find them it validates them.)

So, the parsers should be accepting that document. What parser does not
accept it?

Hope that helps,
Priscilla
 
M

Michael Kremser

Hi Priscilla,

Thanks for your answer!

Priscilla said:
It is valid for SomeThing to appear there, even if it is not declared.

When you specify processContents="lax", it means that it looks for
declarations for the elements like SomeThing but if it doesn't find them
it doesn't raise an error. (If it does find them it validates them.)

That's exactly how I interpreted the documentation!
So, the parsers should be accepting that document. What parser does not
accept it?

MS XML 4 has accepted it, but the .net FX classes behave differently.
Here is an example what .net 2.0.41115 "thinks":

http://www.mkcs.at/temp/pub/w2k3_vsnet2005_xsd_validator.jpg

A colleague found a Java XSD validator in the Internet, which says the
XML is correct. So we were confused that "older" parsers accepted it,
but "newer" one (at least, those from Microsoft) say there is an error.

I'll post this as a bug, because also VS.net 2005 Beta 2 thinks the XML
is not valid though it is as we know now.
Hope that helps,

Yes, it did. :)
Priscilla

Thanks again and best regards,

Michael
 
M

Michael Kremser

Hi Martin,

Thanks for your reply!
Which parsers have you tried, which say the snippet is valid, which say
it is not?

Please see the answer to Priscilla's Posting.

Best regards,

Michael
 
S

Stan Kitsis [MSFT]

Hi Michael,

VS 2005 Beta 2 does not exist yet. So I'm not sure which version you are
using - must be beta 1. Anyway, I just tried it with the build I have on my
machine and your XML validates just fine. So even if there is a problem
with earlier versions of VS 2005, it looks like it's should be fixed in
beta2.

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top