[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Problem with XPath in my XSL
When a variable is declared like this: <xsl:variable name="raum" select="raum"></xsl:variable> and there is no child::raum element, the value of $raum is an empty node-set. $raum != "" tests whether any of the nodes in $raum is not equal to "". There aren't any such nodes, so the result is false. You want not($raum = "") Alternatively, make your variable a string by writing it as <xsl:variable name="raum" select="string(raum)"/> An empty node-set will then be converted to an empty string. Michael Kay > -----Original Message----- > From: Christian Barth [mailto:christian@xxxxxxxxxxxxx] > Sent: 23 January 2006 14:49 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: Problem with XPath in my XSL > > Hi! > > I use the XPath-Operator "and" to test some variables in a > xsl:choose. See > the code: > > <xsl:template match="ergebnis"> > <xsl:for-each select="objekt"> > <xsl:variable name="bau" select="bauvorhaben"></xsl:variable> > <xsl:variable name="geb" select="gebaeude"></xsl:variable> > <xsl:variable name="stock" select="stockwerk"></xsl:variable> > <xsl:variable name="NZ" select="nutzungszone"></xsl:variable> > <xsl:variable name="raum" select="raum"></xsl:variable> > <tr> > <td align="center"><b><xsl:value-of select='@id'/></b></td> > <xsl:choose> > <!-- A-SUCHE --> > <xsl:when test="$typ = 'A'"> > <xsl:choose> > <!-- F|r Elemente, die auf Gebaeude-Ebene liegen --> > <xsl:when test="$geb != '' and $stock = '' and $NZ = '' and > $raum = ''"> > <td>Gebaeude "<xsl:value-of select="$geb" />" in Bauvorhaben > "<xsl:value-of select="$bau" />"<p></p> > Elemente kvnnten f|r Sie von Interesse sein:<br></br> > <xsl:for-each select="*"> > <xsl:choose> > <xsl:when test="local-name() = 'gebTrennwaende'"> > <xsl:call-template name="Datenanzeige"> > <xsl:with-param name="element" > select="gebTrennwand" > /> > </xsl:call-template> > </xsl:when> > </xsl:choose> > </xsl:for-each> > </td> > </xsl:when> > <!-- F|r Elemente, die auf Stockwerk-Ebene liegen --> > ------------------------------------------------------------------- > <!-- THIS TEST SHOULD BE TRUE --><xsl:when test="$stock != '' > and $NZ = '' > and $raum = ''"> > ------------------------------------------------------------------- > <td>Stockwerk "<xsl:value-of select="$stock" />" von Gebaeude > "<xsl:value-of select="gebaeude" />" in Bauvorhaben "<xsl:value-of > select="bauvorhaben" />"<p></p> > Elemente kvnnten f|r Sie von Interesse sein:<br></br> > <xsl:for-each select="*"> > <xsl:choose> > <xsl:when test="local-name() = 'rettungswege'"> > <xsl:call-template name="Datenanzeige"> > <xsl:with-param name="element" select="rw" /> > </xsl:call-template> > </xsl:when> > <xsl:when test="local-name() = 'trennwaende'"> > <xsl:call-template name="Datenanzeige"> > <xsl:with-param name="element" > select="trennwand" /> > </xsl:call-template> > </xsl:when> > </xsl:choose> > </xsl:for-each> > </td> > </xsl:when> > <xsl:otherwise> > <td>Gebaeude "<xsl:value-of select="$geb" />" in Bauvorhaben > "<xsl:value-of select="$bau" />"</td> > </xsl:otherwise> > </xsl:choose> > <td align="center"><b><xsl:value-of select="gesamtSim" /></b></td> > </xsl:when> > <!-- B-SUCHE --> > <xsl:when test="$typ = 'B'"> > <td><xsl:value-of select="@typ" /> "<xsl:value-of > select="bezeichnung" > />" aus Bauvorhaben "<xsl:value-of select="bauvorhaben" />" > in Gebaeude > "<xsl:value-of select="gebaeude" />"</td> > <td align="center"><b><xsl:value-of select="gesamtSim" /></b></td> > </xsl:when> > <!-- C-SUCHE --> > <xsl:when test="$typ = 'C'"> > noch > </xsl:when> > <xsl:otherwise> > noch > </xsl:otherwise> > </xsl:choose> > </tr> > </xsl:for-each> > </xsl:template> > > > > In the XML-doc used for testing this stuff, there are only the Tags > <gebaeude> and <stockwerk>. So the other variables are empty. The > xsl-processor should than enter the bold "when-clause". But > it always goes > to the otherwise-Tag. > > I just don't see why? Can anybody help me please? > > Thanks, > Barthi
|
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
|