xsl-list
[Top] [All Lists]

RE: [xsl] [XSLT 1.0] Replace namespace prefixes?

2009-12-24 12:00:55
I think it'd be possible to do this by putting the literal namespace at the top 
of your stylesheet (or in a child element), and with something like a 
<xsl:copy-of select="document('')/*/namespace::bk" /> after (or as) you copy 
the top level element. YMMV, but remember that you can select and manipulate 
the actual namespace nodes in XPath/XSLT.

~ Scott


-----Original Message-----
From: Costello, Roger L. [mailto:costello(_at_)mitre(_dot_)org] 
Sent: Thursday, December 24, 2009 10:39 AM
To: 'xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com'
Subject: [xsl] [XSLT 1.0] Replace namespace prefixes?


Hi Folks,

I would like an identify transform that replaces namespace prefixes with my own 
names.

For example, I would like to transform this:

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

Into this:

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

Or this:

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

Is there a way to replace namespace prefixes, using XSLT 1.0?

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


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