Subject: RE: [xsl] Tag's depending on cousin element From: Jarno.Elovirta@xxxxxxxxx Date: Thu, 10 Jul 2003 11:33:08 +0300 |
Hi, > First, I don't know if the test will function at all since > they are empty > elements. They do. See <http://www.w3.org/TR/xslt#section-Conditional-Processing-with-xsl:choose> and <http://www.w3.org/TR/xpath#section-Boolean-Functions>. > If they work, how would I (in future) be able to test if the > element is > empty? Try to select it's children. "foo/node()" for any child, "foo/*" for elements children, and so forth. > Second, I don't like my solution at all. It is not verey > generic, and for > each new state introduced (I have no control over this), my > "state" template > doubles in size. > > Is there some smarter way of doing this? > A more elaborate answer than "yes" or "no" will be appreciated :) For example <xsl:template match="lv"> <xsl:copy> <xsl:choose> <xsl:when test="state/*"> <xsl:apply-templates select="state/*[1]" mode="x"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="declaration"/> </xsl:otherwise> </xsl:choose> </xsl:copy> </xsl:template> <xsl:template match="*" mode="x"> <xsl:copy> <xsl:choose> <xsl:when test="following-sibling::*"> <xsl:apply-templates select="following-sibling::*[1]" mode="x"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="../../declaration"/> </xsl:otherwise> </xsl:choose> </xsl:copy> </xsl:template> or <xsl:template match="lv"> <xsl:copy> <xsl:apply-templates select="(state/* | declaration)[1]" mode="x"/> </xsl:copy> </xsl:template> <xsl:template match="*" mode="x"> <xsl:copy> <xsl:apply-templates select="following::*[1]" mode="x"/> </xsl:copy> </xsl:template> <xsl:template match="declaration" mode="x"> <xsl:value-of select="."/> </xsl:template> Cheers, Jarno - C-Drone Defect: Psycho2vii XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Tag's depending on cousin, David Carlisle | Thread | RE: [xsl] Tag's depending on cousin, Ragulf Pickaxe |
Re: [xsl] identity transform - incl, David Carlisle | Date | Re: [xsl] Tag's depending on cousin, David Carlisle |
Month |