Subject: RE: [xsl] XML to XML From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 26 Mar 2003 17:54:07 -0500 |
Cheers, Wendell
Untested but try the following approach
<xsl:template match="Categories">
<Categories>
<xsl:apply-templates select="Category[length(string(Code))=1]" />
</Categories>
</xsl:template>
<xsl:template match="Category">
<xsl:variable name="code" select="string(Code)"/>
<xsl:variable name="code-length" select="length(string(Code))"/>
<xsl:variable name="name">
<xsl:choose>
<xsl:when test="length(string(Code))=1">LevelOneCategory</xsl:when>
...etc
</xsl:choose>
</xsl:variable>
<xsl:element name="{$name}" Code="{$code}" Description="{Description}">
<xsl:apply-templates select="following-sibling::Category[substring(string(Code),1,$code-length)=string($code)]" />
</xsl:element>
</xsl:template>
following-sibling:: could be replaced with ../ if the order is not guaranteed.
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] XML to XML, Wendell Piez | Thread | RE: [xsl] XML to XML, Jim Han |
Re: [xsl] XML to XML, Wendell Piez | Date | RE: [xsl] xsl:function, Mac Martine |
Month |