Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » XML Schema Definition (XSD) » Substitution Group
Substitution Group [message #67770] Tue, 18 April 2006 11:21 Go to next message
tatini venkate is currently offline tatini venkateFriend
Messages: 19
Registered: July 2009
Junior Member
Hi

I have a schema file which has 'persons' as root element.
'persons' has 'person' as child element which has 'Name' as child element.

I declared another element called 'FirstName' which can be substituted to
element 'Name'

Now I need to identify what are all the elements can be substuted in place
of element 'Name'.

In the above example I can use 'FirstName' instede of 'Name' in my XML doc.

Is there any way to get substitution list from XSD parser ?.

Here I am attaching sample schema and XML docs.

Thanks
Param

Family.xsd

<?xml version="1.0" encoding="ISO-8859-1"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.gxs.com" targetNamespace="http://www.gxs.com"
elementFormDefault="qualified">
<xs:element name="person" >
<xs:complexType>
<xs:sequence>
<xs:element ref="Name"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="persons">
<xs:complexType>
<xs:sequence>
<xs:element ref="person" maxOccurs="40" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Name" type="xs:string"/>
<xs:element name="FirstName" type="xs:string" SubstitutionGroup="Name"/>
</xs:schema>

Family.xml

<?xml version="1.0" encoding="UTF-8"?>
<!--Sample XML file generated by XMLSpy v2005 rel. 3 U
(http://www.altova.com)-->
<persons xmlns="http://www.gxs.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.gxs.com
family.xsd">
<person>
<Name>Name</Name>
</person>
<person>
<FirstName>FirstName</FirstName>
</person>
</persons>
Re: Substitution Group [message #67792 is a reply to message #67770] Tue, 18 April 2006 12:11 Go to previous message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Param,

XSDElementDeclaration.getSubstitutionGroup should yield the list of
substitutable element declarations.


aram wrote:
> Hi
>
> I have a schema file which has 'persons' as root element.
> 'persons' has 'person' as child element which has 'Name' as child
> element.
>
> I declared another element called 'FirstName' which can be substituted
> to element 'Name'
>
> Now I need to identify what are all the elements can be substuted in
> place of element 'Name'.
>
> In the above example I can use 'FirstName' instede of 'Name' in my XML
> doc.
>
> Is there any way to get substitution list from XSD parser ?.
>
> Here I am attaching sample schema and XML docs.
>
> Thanks
> Param
>
> Family.xsd
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.gxs.com" targetNamespace="http://www.gxs.com"
> elementFormDefault="qualified">
> <xs:element name="person" >
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="Name"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="persons">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="person" maxOccurs="40" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="Name" type="xs:string"/>
> <xs:element name="FirstName" type="xs:string"
> SubstitutionGroup="Name"/>
> </xs:schema>
>
> Family.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!--Sample XML file generated by XMLSpy v2005 rel. 3 U
> (http://www.altova.com)-->
> <persons xmlns="http://www.gxs.com"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.gxs.com
> family.xsd">
> <person>
> <Name>Name</Name>
> </person>
> <person>
> <FirstName>FirstName</FirstName>
> </person>
> </persons>
>
Re: Substitution Group [message #597982 is a reply to message #67770] Tue, 18 April 2006 12:11 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Param,

XSDElementDeclaration.getSubstitutionGroup should yield the list of
substitutable element declarations.


aram wrote:
> Hi
>
> I have a schema file which has 'persons' as root element.
> 'persons' has 'person' as child element which has 'Name' as child
> element.
>
> I declared another element called 'FirstName' which can be substituted
> to element 'Name'
>
> Now I need to identify what are all the elements can be substuted in
> place of element 'Name'.
>
> In the above example I can use 'FirstName' instede of 'Name' in my XML
> doc.
>
> Is there any way to get substitution list from XSD parser ?.
>
> Here I am attaching sample schema and XML docs.
>
> Thanks
> Param
>
> Family.xsd
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.gxs.com" targetNamespace="http://www.gxs.com"
> elementFormDefault="qualified">
> <xs:element name="person" >
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="Name"/>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="persons">
> <xs:complexType>
> <xs:sequence>
> <xs:element ref="person" maxOccurs="40" />
> </xs:sequence>
> </xs:complexType>
> </xs:element>
> <xs:element name="Name" type="xs:string"/>
> <xs:element name="FirstName" type="xs:string"
> SubstitutionGroup="Name"/>
> </xs:schema>
>
> Family.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!--Sample XML file generated by XMLSpy v2005 rel. 3 U
> (http://www.altova.com)-->
> <persons xmlns="http://www.gxs.com"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://www.gxs.com
> family.xsd">
> <person>
> <Name>Name</Name>
> </person>
> <person>
> <FirstName>FirstName</FirstName>
> </person>
> </persons>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Substitution Group
Next Topic:XML Generation and element hiding
Goto Forum:
  


Current Time: Thu Mar 28 09:10:13 GMT 2024

Powered by FUDForum. Page generated in 0.03807 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top