Re: [xsl] [XSLT] Asking or Update variable

Subject: Re: [xsl] [XSLT] Asking or Update variable
From: "Sam Byland" <shbyland@xxxxxxxxxxx>
Date: Wed, 12 Mar 2008 11:54:58 -0400
Izaskun,

at first I thought this was a repeat of your original post, but I see you've added an xsl:choose at the bottom of your question. Did you take a look at Dr. Kay's response? It simplifies your XSLT by replacing the two xsl:for-each statements with the xsl:variable, and allows you to use the variable IsSubclass in the subsequent xsl:choose per your request. For example, here would be the updated xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
<xsl:param name="class">PersonList</xsl:param>
<xsl:param name="subclass">rdfs:subClassOf</xsl:param>


<xsl:template match="rdf:RDF">

<xsl:variable name="IsSubClass" select="boolean(*[@rdf:ID=$class]/*[name()=$subclass])"/>

   <xsl:choose>
     <xsl:when test="IsSubclass">
     ...
     </xsl:when>
     <xsl:otherwise>
     ...
     </xsl:otherwise>
   </xsl:choose>

</xsl:template>

</xsl:stylesheet>

...sam

Current Thread