By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

XmlSchema find element question/best practice solution.

P: n/a
Hi,

I have a simple XSD for example like this:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:element name="customer">
<xs:complexType mixed="false">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:int"/>
</xs:sequence>
<xs:anyAttribute namespace="##any"/>
</xs:complexType>
</xs:element>
</xs:schema>

I also have a simple template attribute language engine to process an XHTML
document and in one of the attribute I have a directive for example
"/customer/age" (derived from the XPath here). When the engine see this
directive it needs to replace the content of that tag with the apropriate
HTML fragment. To find the correct HTML fragment i need to find out the type
based on the XSD. In this example it will be xs:int.

The question is how do I get the type from my XSD given the "/customer/age"
information? Is this possible to do so? Anyone has any hint for this?

Thanks

Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
The XmlSchema class exposes a Elements collection which exposes all
XmlSchemaElement object corresponding to all the global elements in the XSD
schema (like customer). You can then access the ElementType property to
obtain an instance of the XmlSchemaType corresponding to the type in the
schema

"Victor Hadianto" <sy***@nospam.nospam> wrote in message
news:F7**********************************@microsof t.com...
Hi,

I have a simple XSD for example like this:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xs:element name="customer">
<xs:complexType mixed="false">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="age" type="xs:int"/>
</xs:sequence>
<xs:anyAttribute namespace="##any"/>
</xs:complexType>
</xs:element>
</xs:schema>

I also have a simple template attribute language engine to process an XHTML document and in one of the attribute I have a directive for example
"/customer/age" (derived from the XPath here). When the engine see this
directive it needs to replace the content of that tag with the apropriate
HTML fragment. To find the correct HTML fragment i need to find out the type based on the XSD. In this example it will be xs:int.

The question is how do I get the type from my XSD given the "/customer/age" information? Is this possible to do so? Anyone has any hint for this?

Thanks

Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.