[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Q: XSLT 1.0 output of namespace

Subject: Q: XSLT 1.0 output of namespace
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Mon, 16 Aug 2010 14:35:00 +0200
 Q: XSLT 1.0 output of namespace
Hello,

this is a pure XSLT 1.0 question.

Below template does the (readable) output of the current node even for
attribute and namespace nodes.
In the spec the following is stated:
  "There is no pattern that can match a namespace node, ...".

So I tried it with negative matches for node, pi, comment and text.
But now the differentiation between namespace node and attribute node
( for output of  xnlns:ns1="..." / xmlns="..." / attr="..." )
seems a bit complex to me.

Can this be simplified?


  <xsl:template match="@*">
    attribute
  </xsl:template>

  <xsl:template name="doOutput">
    <xsl:choose>
      <!-- attribute could be matched, namespace not - handle both -->
      <xsl:when test="not(node()|processing-instruction()|comment()|text
())">
        <xsl:variable name="isAttribute">
          <xsl:apply-templates select="."/>
        </xsl:variable>
        <xsl:if test="$isAttribute=''">
          <xsl:text>xmlns</xsl:text>
          <xsl:if test="name()">:</xsl:if>
        </xsl:if>
        <xsl:value-of select="name()"/>
        <xsl:text>="</xsl:text>
        <xsl:value-of select="string()"/>
        <xsl:text>"</xsl:text>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy-of select="."/>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>



Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.