Groups | Blog | Home
all groups > dotnet xml > march 2006 >

dotnet xml : XML Schema with unnkown Element names


Priya Lakshminarayanan
3/20/2006 3:13:36 PM
You can do it by using xsi:type in the instance as shown below:
<WellKnown xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<UnknownA xsi:type="unKnownTypeWithAtt" Type="123">
<UnknownChildA Type="String" xsi:type="unKnownTypeWithAtt"/>
<UnknownChildB Type="345" xsi:type="unKnownTypeWithAtt"/>
</UnknownA>
</WellKnown>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="WellKnown" type="unKnownTypeWithAtt">
</xs:element>

<xs:complexType name="unKnownTypeWithAtt">
<xs:sequence>
<xs:any processContents="lax" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="Type" type="xs:int"/>
</xs:complexType>
</xs:schema>

There is no other way in XML Schema to describe elements with unknown names
except xs:any.

Thanks,
Priya

[quoted text, click to view]

Mark Doerbandt
3/20/2006 10:29:48 PM
Hi,

I need to validate a XML document where some of the element names are
unnknown.

<xs:any processContents="lax"/> or "skip" allows me to do so.

But: I want to validate those elements - the only thing unknown is the
name of the elements. Especially the attributes are well-known and
need to be validated.

a) Is there any option to use regExp with the name attribute?

b) Or any other way to describe elements with unnkonw names?

I cannot change the XML instance document.

Thanks! Mark

Example data:

<?xml version="1.0"?>
<root>
<WellKnown Type="TypeFromList" Name="anyName">
<UnknownA Type="TypeFromList" Width="200">
<UnknownChildA Type="String"/>
<UnknownChildB Type="String"/>
</UnknownA>
<UnknownB Type="TypeFromList" Width="200">
<UnknownChildC Type="Date"/>
<UnknownChildD Type="Currency"/>
</UnknownB>
</WellKnown>
<WellKnown Type="TypeFromList" Name="anyOtherName"/>
</root>

Mark Doerbandt
3/22/2006 12:00:00 AM
Thanks, Priya,

Priya Lakshminarayanan:

[quoted text, click to view]

for your response.

[quoted text, click to view]

Unfortonately I'd have to change the instance for that - and I'm not
able to do so.

[quoted text, click to view]

OK - so I'll have to talk to my customer so /they'll/ change the
schema.

AddThis Social Bookmark Button