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

Getting at namespace-prefix used in source document

Subject: Getting at namespace-prefix used in source document
From: "Christian Roth" <roth@xxxxxxxxxxxxxx>
Date: Sun, 10 Sep 2006 16:22:03 +0200
prefix use
Hello,

is there a way in XSLT to determine the namespace prefix used in the
source document for a given namespace name?

The issue I need to solve is that I have a source document with
namespaced elements, which I need to move to the null (or some other)
namespace using XSLT. However, the source document also includes an
embedded CSS 2.1 stylesheet, which of course is written in a way to
match the prefixes used in the source. When porting the document to the
null namespace, I have to remove the prefixes in the CSS 2.1 code too,
see this conceptual example:

--source--
<ns:document xmlns:ns="http://example.com" xmlns:html="http://the-usual-ns">
  <ns:style type="text/css">
    ns\:par { font-weight: bold; }
    html\:table { width: 10cm; }
  </style>
  <ns:par>A paragraph.</ns:par>
  ...
</ns:document>


--desired result--
<document xmlns:html="http://the-usual-ns">
  <style type="text/css">
    par { font-weight: bold; }
    html\:table { width: 10cm; }
  </style>
  <par>A paragraph.</par>
  ...
</document>


To make my stylesheet independent from the namespace prefix actually
used in the source document, I think I need to know the namespace prefix
used for "http://example.com" in the source document. Is there a way to
get at this, or is the only solution to pass it as a parameter to my
XSLT (and seeing how I can provide this info, e.g. by some custom code
peeping into the XML with a little SAX parsing)?

Regards, Christian.

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.