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

Re: Identity transform (case conversion)

Subject: Re: Identity transform (case conversion)
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Sat, 8 Jul 2006 21:45:38 +0530
xsl transform to all caps
Thanks Dimitre for the clarifications..

Here is the code which doesn't work fine with MSXML4.

This stylesheet:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

xmlns:msxsl="urn:schemas-microsoft-com:xslt"
                                          exclude-result-prefixes="msxsl">

<xsl:output method="xml" indent="yes" encoding="UTF-8" />

  <xsl:variable name="small" select="'abcdefghijklmnopqrstuvwxyz'" />
  <xsl:variable name="caps" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />

  <xsl:template match="*">
    <xsl:element name="{translate(name(), $small, $caps)}">
      <xsl:variable name="nsHolder">
        <test>
          <xsl:for-each select="namespace::*">
            <xsl:attribute name="{translate(name(), $small,
$caps)}:dummy{position()}" namespace="{translate(., $small,
$caps)}"></xsl:attribute>
          </xsl:for-each>
        </test>
      </xsl:variable>
      <xsl:copy-of select="msxsl:node-set($nsHolder)/test/namespace::*"/>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:element>
  </xsl:template>

  <xsl:template match="text()">
    <xsl:value-of select="translate(., $small, $caps)" />
  </xsl:template>

  <xsl:template match="@*">
    <xsl:attribute name="{translate(name(), $small, $caps)}"
namespace="{translate(namespace-uri(), $small, $caps)}"><xsl:value-of
select="translate(., $small, $caps)" /></xsl:attribute>
  </xsl:template>

  <xsl:template match="processing-instruction()">
    <xsl:processing-instruction name="{translate(name(), $small,
$caps)}"><xsl:value-of select="translate(., $small, $caps)"
/></xsl:processing-instruction>
  </xsl:template>

  <xsl:template match="comment()">
    <xsl:comment><xsl:value-of select="translate(., $small, $caps)"
/></xsl:comment>
  </xsl:template>

</xsl:stylesheet>

When applied to this XML:

<?xml version="1.0" ?>
<!-- this is a comment -->
<?pqr x="do-something" ?>
<author xmlns:a="xyz" xmlns:b="pqr">
<person a:age="30"> by <FirstName>Jane</FirstName>
<LastName>Doe</LastName>,
</person>
</author>

produces output:

<?xml version="1.0" encoding="UTF-8"?>
<!-- THIS IS A COMMENT -->
<?PQR X="DO-SOMETHING" ?>
<AUTHOR xmlns:auto-ns1="HTTP://WWW.W3.ORG/XML/1998/NAMESPACE"
xmlns:A="XYZ" xmlns:B="PQR">
<PERSON A:AGE="30"> BY <FIRSTNAME>JANE</FIRSTNAME>
<LASTNAME>DOE</LASTNAME>,
</PERSON>
</AUTHOR>

Regards,
Mukul

On 7/8/06, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> Why at all the namespace, http://www.w3.org/xml/1998/namespace is part
> of node-set namespace::*. I am not sure, but does it relate to the XML
> Namespaces spec? (you hinted this in your previous answers)
>


How do you expect otherwise to be able to use an "xml:lang" attribute and a few more in this namespace without explicitly specifying the xml namespace?

So, the answer to your question is that this is a convenient default.

From the XML Namespace errata:

"Namespace constraint: Reserved Prefixes and Namespace Names

The prefix xml is by definition bound to the namespace name
http://www.w3.org/XML/1998/namespace. It may, but need not, be
declared, and must not be bound to any other namespace name. No other
prefix may be bound to this namespace name."

Note also that the namespace-uri used in your code is different from
the namespace-uri for the xml namespace -- as others advised this
answers your first question.

Could you send me the code, which causes MSXML4 to produce non-"xml"
bindings to the xml namespace uri?


-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence.

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.