Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] XML Question

From: Abel Braaksma <abel.online@--------->
To:
Date: 10/3/2006 10:40:00 PM
LINKE Markus wrote:
I think I missunderstood something ...

  

I think you use a rather complex stylesheet to accomplish your rather 
trivial task (imho). One of the steps missing is that you have to 
replace 'myNamespace' with your namespace, but it looks like you don't 
use a namespace at all. Let me give it a try with a simpler stylesheet 
that just processes your nodes (I happened to accidentally be working on 
something similar for a simple analysis function, a little tweaking gave 
me this):



(make sure to have set xsl:output to text and call it using 
apply-templates with the right mode)

(also note, as a convenience, I added two global params/variables to 
decide on whether you want to see the path growing and shrinking or not: 
$wind-up and $wind-down)



<!--

      this will process and output all nodenames as if these were paths

      it will NOT output the textual contents of the nodes. But you can 
add that

      yourself easily if you like. It does not require node-set and 
works for xslt 1.0 and 2.0

-->



   <xsl:template match="*" mode="nodenames">

       <xsl:param name="current-path" select="''" />

      
       <xsl:choose>

           <!--

               'End' of the xpath: no other children to parse

           -->

           <xsl:when test="not(./*)">

               <xsl:text>&tab;</xsl:text>

               <xsl:value-of select="concat($current-path, '/', 
local-name())" />

               <xsl:text>&newline;</xsl:text>

           </xsl:when>

          
           <!--

               Still children to parse.

           -->

           <xsl:otherwise>

              
               <!--

                   Use global param to set winding/unwinding 
               -->

               <xsl:if test="$wind-up = 'yes'">

                   <xsl:text>&tab;</xsl:text>

                   <xsl:value-of select="concat($current-path, '/', 
local-name())" />

                   <xsl:text>&newline;</xsl:text>

               </xsl:if>

              
               <!--

                   Apply all children

               -->

               <xsl:apply-templates select="./*" mode="nodenames" >

                   <xsl:with-param name="current-path" 
select="concat($current-path, '/', local-name())" />

               </xsl:apply-templates>

              
               <!--

                   Use global param to set winding/unwinding

               -->

               <xsl:if test="$wind-down = 'yes'">

                   <xsl:text>&tab;</xsl:text>

                   <xsl:value-of select="concat($current-path, '/', 
local-name())" />

                   <xsl:text>&newline;</xsl:text>

               </xsl:if>

           </xsl:otherwise>

       </xsl:choose>

   </xsl:template>


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent