Re: [xsl] getting node type in xsl

Subject: Re: [xsl] getting node type in xsl
From: David Carlisle <davidc@xxxxxxxxx>
Date: Tue, 7 Sep 2004 17:04:46 +0100
  unfortunately using asp.net I am bound to xslt version 1.0, as they
  will not implement version 2 even in the next version of their
  framework.
  or is there another .net xslt processor around, where I can leverage version2.0?


An alternative that would work in xslt1 (or a non-schema xslt2
processor) is to pre-process your schema using xslt to produce an xslt
file that "knows" the element types. If your schema is highly complex
this might be difficult but for many schema documents it is relatively easy
to write an xslt file that inputs a schema and (say) collects all the
element names that have type xsd:integer and outputs

<xsl:template mode="type" match="elem1|elem2|....|last-element">
 <xsl;text>integer</xsl:text>
</xsl:template>

then, having produced this xsl file you can import that into your main
xslt file and whenever you need to know the type of an element
just apply this type mode to get the type name of the current element.

<xsl:variable name="type">
 <xsl;apply-templates mode="type" select="."/>
</xsl:variable>
<xsl:if test="$type='integer'">
  do something about integers...

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread