[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: Dylan Walsh <Dylan.Walsh@xxxxxx>
Date: Fri, 5 Nov 1999 14:11:01 -0000
dylan walsh
>Date: Thu, 4 Nov 1999 17:48:58 -0700 
>From: Mike Brown <mbrown@xxxxxxxxxxxxx>
>Subject: RE: Accessing the XML declaration, the namespace-uri()
function
>
>Dylan Walsh wrote:
>> Is it possible to somehow access the attributes of the <?xml
>> version="1.0"?> tag?
>
>No. An XML parser looks at the XML declaration so that it can know how
to go
>about interpreting the character data that comprises the rest of the
>document. The declaration is not fed by the XML parser into your XSL
>processor.

It seems you can with IE5. 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'm trying to create a stylesheet that will generate a
>> HTML view of any XML code
>
>A stylesheet that generates an HTML view of XML *code* is one thing. A
>stylesheet that generates an HTML view of the *node tree* that XML code
>*represents* is something altogether different.

What I have created is a stylesheet which gives you a view of your XML
file in your web browser via standard HTML.
The code is indented and highlighted i.e. the output when viewed in a
brower looks like your XML code, only indented & color coded.
Mine does everything except show the <?XML?> declaration and the
namespaces.

>> Would it be safe to assume that the declaration is always
>> <?xml version="1.0"?> and hard code it, i.e.:
>> &lt;?xml version="1.0"?&gt; ?
>
>No, it's not safe to assume. If you are trying to HTMLize the code (of
which
>the XML declaration and entity references are a part) and not the node
tree,
>then you need to avoid feeding the XML source document to your XSL
processor
>in a manner that causes the document to be split up into the tree of
nodes
>that the document represents. (i.e., good luck.) I suspect that you are
>actually trying to HTMLize the node tree, which doesn't contain the XML
>declaration or the DTD (yet), so you need to not be worrying about it.

Perhaps I've explained my goal more clearly above ("What I have created
is...").
What I am proposing here is a cheat, which assumes we'll be using <?xml
version="1.0"?> for a while to come.

>> Also, does the namespace-uri() function work in XT? [...]
>> I can't get it to produce anything (using <xsl:value-of
>> select="namespace-uri()> ).

><xsl:value-of select="namespace-uri(foo)"/> will create in the result
tree a
>text node containing the namespace URI of the first node in the
node-set
>identified by the XPath location path 'foo'.
>http://www.w3.org/TR/xpath#section-Node-Set-Functions explains several
>situations which will cause this function to return an empty string.
And if
>you omit the argument, then the context node will be used. Are you sure
your
>context node has a namespace?
>
>- -Mike

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


 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.