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" <spamreceiver@doerbandt.de> wrote in message
news:dvnacs.2l8.1@dit8.doerbandt.de...
> 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>
>
> - how do I validate those Type-attributes of the Unnkown* elements?