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

RE: Accessing the XML declaration, the namespace-uri() funct

Subject: RE: Accessing the XML declaration, the namespace-uri() function
From: Mike Brown <mbrown@xxxxxxxxxxxxx>
Date: Fri, 5 Nov 1999 13:38:40 -0700
accessing xsl xml namespace prefix
> >Dylan Walsh wrote:
> The default XML viewer stylesheet
> uses <xsl:template match="pi('xml')> as I've mentioned in
> another post. Alas this isn't possible with up to date XSL.

I missed the other post, but yeah, the XPath spec says:
"NOTE: The XML declaration is not a processing instruction.
Therefore, there is no processing instruction node
corresponding to the XML declaration."

What I can't figure out is if you're trying to
reconstruct the XML document based solely on what the
XSL processor sees in the source tree. If that's the
case, then you not only don't have the <?xml?>
declaration, you also don't have entity references or
the DTD. Nor do you have the original encoding of the
document, so while your original document may say
<?xml version="1.0" encoding="utf-16"?>, your HTML
representation of that is going to likely be using
iso-8859-1. I'm not sure what the ramifications of
this are, but I'm sure it's not pretty.

> I'd like elements which declare names spaces to have 
> xmlns:foo="uri" in my output, as they do in the
> source. I've made some progress with namespace-uri(),
> but I don't think I'll be able to do what I want to
> until XT supports the namespace axis (which will
> allow me to show the name of the namespace).

Oh, right. Namespace declarations are not in the tree
as attribute nodes; they're namespace nodes, which
can only be seen along the namespace axis. The XPath
function namespace-uri() exposes the namespace URI
of an element, but the prefix would have to be
deduced by looking for descendants that use it. This
is theoretically do-able if you look for a non-null
substring-before(":",name(.)) for each element and
attribute that has the namespace URI in question and
that is located on the descendant-or-self axis. But
this wouldn't catch cases where the prefix is
declared but never used, or where the prefix is
used incorrectly outside of its scope.


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.