xsl-list
[Top] [All Lists]

[xsl] Namespace and XSL Variables

2006-09-12 07:16:13
Hi:

I have an xml stream that is formed from three different xml sources
(Source1, Source2, Source3) and then folded into a single xml stream.
The single xml stream has this structure:

<Document>
     <Source1>
          ...
     </Source1>
     <Source2 xmlns:"http://www.somenonexistenturl.com";>
          <Results selected="123">
               <Path cp="123">blah blah blah</Path>
               <Path cp="124">la dee da</Path>
               <Path cp="125">ha</Path>
          </Results>
     </Source2>
     <Source3>
          ...
     </Source3>
</Document>

I'm using xsl to create a web page. I pull data from the three 'Source'
elements randomly throughout the stylesheet:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:x="http://www.somenonexistenturl.com";>
<xsl:output method="html" indent="no" />
<xsl:template match="/">
     ...
     <xsl:variable name="varResultsId"
select="//x:Source2/x:Results/@x:selected" />
     <xsl:for-each select="//x:Source2/x:Results/x:Path">
          <xsl:choose>
               <xsl:when test="$varResultsId = @cp">
                    do one thing
               </xsl:when>
               <xsl:otherwise>
                    do something else
               </xsl:otherwise>
          </xsl:choose>
     </xsl:for-each>
     ...
</xsl:template>
</xsl:stylesheet>

While I can get the data within the loop with no problem, I cannot seem
to get the xsl:variable to work with the namespace prefixes. Can you
tell me what I'm doing wrong?

Second question: Is there anyway to access the data in Source2 from the
Document node without using "//"?

Thanks!
Trish

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>