Subject: RE: [xsl] copy-of problem... From: Américo Albuquerque <melinor@xxxxxxx> Date: Tue, 15 Jul 2003 15:17:55 +0100 |
Hi > -----Original Message----- > From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx > [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of > David.Pawson@xxxxxxxxxxx > Sent: Monday, July 14, 2003 12:01 PM > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: RE: [xsl] copy-of problem... > > > Hi Jeni. > > As usual, the easiest recourse here is to use DOE (this is > what it's > > designed for): > > > > <xsl:template match="description"> > > <xsl:value-of select="." disable-output-escaping="yes" /> > > </xsl:template> > > Well it works Jeni... but I would like to know just why. > I've never had to use doe before. If you don't want to use doe you could use these templates: <xsl:template match="description"> <xsl:copy> <xsl:call-template name="parse"/> </xsl:copy> </xsl:template> <xsl:template name="parse"> <xsl:param name="str" select="."/> <xsl:choose> <xsl:when test="contains($str,'<')"> <xsl:variable name="tag" select="substring-before(substring-after($str,'<'),'>')"/> <xsl:variable name="endTag"> <xsl:choose> <xsl:when test="contains($tag,' ')"> <xsl:value-of select="substring-before($tag,' ')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="$tag"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:call-template name="parse"> <xsl:with-param name="str" select="substring-before($str,concat('<',$tag,'>'))"/> </xsl:call-template> <xsl:call-template name="parseTag"> <xsl:with-param name="tag" select="$tag"/> <xsl:with-param name="endTag" select="normalize-space($endTag)"/> <xsl:with-param name="value" select="substring-before(substring-after($str,concat('<',$tag,'>')),co ncat('</',normalize-space($endTag),'>'))"/> </xsl:call-template> <xsl:call-template name="parse"> <xsl:with-param name="str" select="substring-after($str,concat('</',normalize-space($endTag),'>') )"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:value-of select="$str"/> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="parseTag"> <xsl:param name="tag" select="''"/> <xsl:param name="endTag" select="''"/> <xsl:param name="value" select="''"/> <xsl:element name="{$endTag}"> <xsl:call-template name="attribs"> <xsl:with-param name="attrlist" select="substring-after(normalize-space($tag),' ')"/> </xsl:call-template> <xsl:call-template name="parse"> <xsl:with-param name="str" select="$value"/> </xsl:call-template> </xsl:element> </xsl:template> <xsl:template name="attribs"> <xsl:param name="attrlist" select="''"/> <xsl:variable name="name" select="normalize-space(substring-before($attrlist,'='))"/> <xsl:if test="$name"> <xsl:variable name="value"> <xsl:choose> <xsl:when test="substring-before($attrlist,'="')"> <xsl:value-of select="substring-before(substring-after($attrlist,'="'),'"')"/> </xsl:when> <xsl:when test="substring-before($attrlist,'= "')"> <xsl:value-of select="substring-before(substring-after($attrlist,'= "'),'"')"/> </xsl:when> <xsl:when test="substring-before($attrlist,"='")"> <xsl:value-of select="substring-before(substring-after($attrlist,"='"),&quo t;'")"/> </xsl:when> <xsl:when test="substring-before($attrlist,"= '")"> <xsl:value-of select="substring-before(substring-after($attrlist," ='"),"'")"/> </xsl:when> </xsl:choose> </xsl:variable> <xsl:attribute name="{$name}"> <xsl:value-of select="$value"/> </xsl:attribute> </xsl:if> <xsl:choose> <xsl:when test="contains($attrlist,' ')"> <xsl:call-template name="attribs"> <xsl:with-param name="attrlist" select="substring-after($attrlist, ' ')"/> </xsl:call-template> </xsl:when> </xsl:choose> </xsl:template> (...) Hope this helps you Regards, Américo Albuquerque XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] copy-of problem..., Michael Kay | Thread | [xsl] Searching a group of xml docu, bmcleere |
RE: [xsl] spaces between all charac, Nick Vincent | Date | [xsl] Combining XML with XLink to p, Christos Tsoukalas |
Month |