[Home] [By Thread] [By Date] [Recent Entries]
At 2009-12-24 12:36 -0500, Costello, Roger L. wrote:
However, I am interested in a general solution, i.e., for *any* XML document the XSLT transform must output an XML document that is identical to the input, except all namespace prefixes have been replaced by prefixes of the XSLT's choosing. You should have said so! :{)} I hope the example below helps. . . . . . . . . . Ken T:\ftemp>type roger.xml
<attackNOW:book xmlns:attackNOW="http://www.book.org">
<attackNOW:title>The Origin of Wealth</attackNOW:title>
<attackNOW:author>Eric D. Beinhocker</attackNOW:author>
<attackNOW:date>2006</attackNOW:date>
<attackNOW:ISBN>1-57851-777-X</attackNOW:ISBN>
<attackNOW:publisher>Harvard Business School Press</attackNOW:publisher>
<attackNOW:cost currency="USD">29.95</attackNOW:cost>
</attackNOW:book>T:\ftemp>xslt roger.xml roger3.xsl con <?xml version="1.0" encoding="utf-8"?><book xmlns="http://www.book.org"> <title>The Origin of Wealth</title> <author>Eric D. Beinhocker</author> <date>2006</date> <ISBN>1-57851-777-X</ISBN> <publisher>Harvard Business School Press</publisher> <cost currency="USD">29.95</cost> </book> T:\ftemp>xslt roger.xml roger3.xsl con use-this-prefix=bk: <?xml version="1.0" encoding="utf-8"?><bk:book xmlns:bk="http://www.book.org"> <bk:title>The Origin of Wealth</bk:title> <bk:author>Eric D. Beinhocker</bk:author> <bk:date>2006</bk:date> <bk:ISBN>1-57851-777-X</bk:ISBN> <bk:publisher>Harvard Business School Press</bk:publisher> <bk:cost currency="USD">29.95</bk:cost> </bk:book> T:\ftemp>xslt roger.xml roger3.xsl con use-this-prefix=roger: <?xml version="1.0" encoding="utf-8"?><roger:book xmlns:roger="http://www.book.o rg"> <roger:title>The Origin of Wealth</roger:title> <roger:author>Eric D. Beinhocker</roger:author> <roger:date>2006</roger:date> <roger:ISBN>1-57851-777-X</roger:ISBN> <roger:publisher>Harvard Business School Press</roger:publisher> <roger:cost currency="USD">29.95</roger:cost> </roger:book> T:\ftemp>type roger3.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="use-this-prefix"/> <xsl:template match="*[namespace-uri(.)]">
<xsl:element name="{$use-this-prefix}{local-name()}"
namespace="{namespace-uri(.)}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template><xsl:template match="@*|node()"><!--identity for all other nodes-->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> T:\ftemp>
|

Cart



