xsl-list
[Top] [All Lists]

[xsl] Q: XSLT 1.0 output of namespace

2010-08-16 07:37:05

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


--~------------------------------------------------------------------
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>