|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Tag's depending on cousin element
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








