Re: [xsl] xmlns print and enumerate

Subject: Re: [xsl] xmlns print and enumerate
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 08 Mar 2006 15:21:28 -0500
At 2006-03-08 20:35 +0100, M V wrote:
Given the document

<a/>

howe do I transform it to:

<b xmlns:h='http://foo'/>

T:\ftemp>type mv1.xml <a/>

T:\ftemp>xslt mv1.xml mv1.xsl con
<?xml version="1.0" encoding="utf-8"?><b xmlns:h="http://foo"/>
T:\ftemp>type mv1.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

<xsl:template match="a">
  <b xmlns:h='http://foo'/>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>

and given

<a xmlns:h='http://foo'/>

how do I transform it to:

<b>
 <ns prefix='h' uri='http://foo'/>
</b>

T:\ftemp>type mv2.xml <?xml version="1.0" encoding="ISO-8859-1"?> <a xmlns:h='http://foo'/> T:\ftemp>xslt mv2.xml mv2.xsl con <?xml version="1.0" encoding="utf-8"?><b><ns prefix="h" uri="http://foo"/></b> T:\ftemp>type mv2.xsl <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

<xsl:template match="a">
  <b>
    <xsl:for-each select="namespace::*[name(.)!='xml']">
      <ns prefix="{name(.)}" uri="{.}"/>
    </xsl:for-each>
  </b>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>


I hope this helps.


. . . . . . . . . . . . Ken

--
Today is the last day of registration for next week's hands-on XSL courses.

--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-03-13/17
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread