Subject: [xsl] Tokenizing IDREFs From: Stuart Brown <Stuart.Brown@xxxxxxxxxxxxx> Date: Thu, 20 Sep 2001 16:03:41 +0100 |
Hi, I have an input element with an IDREFS type attribute, and I want to split it into separate output element/attribute pairs for each individual IDREF without using xalan: or saxon: extensions (as I want the stylesheet to be independent of processors). To change: <inTag value="ID1 ID2"/> into <bag> <outTag value="ID1"/> <outTag value="ID2"/> </bag> I am using the following (including a test to exclude the <bag> element if there is only one IDREF): <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name="tokenize"> <xsl:param name="string"/> <xsl:choose> <xsl:when test="contains($string,' ')"> <outTag value="{substring-before($string,' ')}"/> <xsl:call-template name="tokenize"> <xsl:with-param name="string"><xsl:value-of select="substring-after($string,' ')"/></xsl:with-param> </xsl:call-template> </xsl:when> <xsl:otherwise> <outTag value="{$string}"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template match="inTag"> <xsl:choose> <xsl:when test="contains(@value,' ')"> <bag> <xsl:call-template name="tokenize"> <xsl:with-param name="string"><xsl:value-of select="@value"/></xsl:with-param> </xsl:call-template> </bag> </xsl:when> <xsl:otherwise> <outTag value="{@value}"/> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet> However, this clearly only functions where the IDREFs are delimited by a single space. I am trying to construct a transformation which will work if the IDREFs are delimited by EITHER a single space OR a line-break, but to absolutely no success. Any pointers, please? Stuart XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] character entities and xs, Michael Kay | Thread | Re: [xsl] Tokenizing IDREFs, David Carlisle |
RE: [xsl] Converting XML source to , Mark Feblowitz | Date | Re: [xsl] Tokenizing IDREFs, David Carlisle |
Month |