Steve,
There is a problem with your schema definition. If you change your schema
definition to just <schema> then the following XSLT will work:
Regards,
Dan
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="
http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/>
<!-- begin -->
<xsl:template match="//schema">
<xsl:apply-templates select="complexType"/>
</xsl:template>
<!-- complexType -->
<xsl:template match="complexType">
<xsl:value-of select="@name"/>
<xsl:text> 	</xsl:text>
<xsl:text>NAME	</xsl:text>
<xsl:text>DATA TYPE	</xsl:text>
<xsl:text>MIN-OCCURANCE	</xsl:text>
<xsl:for-each select="complexContent/extension/sequence/element">
<xsl:text> 	</xsl:text>
<xsl:value-of select="substring-after(@ref,':')"/>
<xsl:text>	</xsl:text>
<xsl:call-template name="GetDataType">
<xsl:with-param name="elementName" select="substring-after(@ref,':')"/>
</xsl:call-template>
<xsl:text>	</xsl:text>
<xsl:value-of select="@minOccurs"/>
</xsl:for-each>
</xsl:template>
<!-- get the data type -->
<xsl:template name="GetDataType">
<xsl:param name="elementName"/>
<xsl:value-of select="preceding::element[@name=$elementName]/@type"/>
</xsl:template>
</xsl:stylesheet>
[quoted text, click to view] "Steve" <shearne@tssg.org> wrote in message
news:cab9fc71.0404211425.4b881c45@posting.google.com...
> I have a Xml schema like the this:
>
> ...
> <schema xmlns = "
http://www.w3.org/2001/XMLSchema" > targetNamespace = "
http://www.ipdr.org/namespaces/ipdr" > xmlns:ipdr = "
http://www.ipdr.org/namespaces/ipdr" > version = "3.0"
> elementFormDefault = "qualified"
> attributeFormDefault = "unqualified">
> <include schemaLocation = "IPDRDoc3.0.xsd"/>
> <element name = "day" type = "string"/>
> <element name = "size" type = "int"/>
> <complexType name = "IPDR-TEST-Type">
> <complexContent>
> <extension base = "ipdr:IPDRType">
> <sequence>
> <element ref = "ipdr:day"/>
> <element ref = "ipdr:size" minOccurs="0"/>
> </sequence>
> </extension>
> </complexContent>
> </complexType>
> </schema>
>
> I would like to be able write code which would output the following to me:
>
> IPDR-TEST-TYPE
> NAME DATA-TYPE MIN-OCCURANCE
> Day string 1
> size int 0
>
> I've tried the following:
>
> reader = new XmlTextReader(getIPDRStructure.FileName);
> schema = XmlSchema.Read(reader,null);
>
> foreach(XmlSchemaObject elem in schema.Items)
> {
> if(elem is XmlSchemaComplexType)
> {
> XmlSchemaComplexType complexType = (XmlSchemaComplexType)elem;
>
> // but complexType.Particle here is null
>
>
> Anybody know how I can do this?