xsl-list
[Top] [All Lists]

[xsl] asthetics vs convention for namespace prefixs

2007-07-26 06:20:33

I'm working on an application where I'd like, for asthetic
reasons, to force the use of a particular xmlns prefix
when dealing with a particular tree of content.

Since, in this situation, I'm in complete control of what
data is being generated and copied, I played around with
trying to encourage the XSLT processor (Saxon in this case)
to use a specific namespace prefix:

  <!-- 
    Convert non-namespaced elements to the xyz namespace.
  -->
  <xsl:template mode="xyz:clone-to-namespace" match="@*|node()">
    <xsl:choose>
      <xsl:when test="self::element() and not(namespace-uri(.))">
        <xsl:element name="xyz:{local-name(.)}"
          namespace="http://schema.example.org/XYZ/Publishing";
          xmlns:xyz="http://schema.example.org/XYZ/Publishing";>
          <xsl:copy-of select="@*" />
          <xsl:apply-templates mode="#current" />
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:copy-of select="@*" />
          <xsl:apply-templates mode="#current" />
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

I know I can't rely on the prefix being used, but is it frowned upon
to try and encourage a specific namespace prefix?

Jim

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
James A. Robinson                       
jim(_dot_)robinson(_at_)stanford(_dot_)edu
Stanford University HighWire Press      http://highwire.stanford.edu/
+1 650 7237294 (Work)                   +1 650 7259335 (Fax)

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