Subject: RE: Accessing the XML declaration, the namespace-uri() function From: Mike Brown <mbrown@xxxxxxxxxxxxx> Date: Thu, 4 Nov 1999 17:48:58 -0700 |
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 might help if you don't think of it as being a "tag", because unlike other tags, it doesn't represent node(s) in the data tree that the XML document describes. Think of it as something on the same "document layer" as entity references like &foo;, where you don't have access to the character sequence & f o o ; ... or perhaps think of it like a header on a uuencoded mail message, where only the decoded body of the message is exposed to the user. > 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. > Would it be safe to assume that the declaration is always > <?xml version="1.0"?> and hard code it, i.e.: > <?xml version="1.0"?> ? 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. > 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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: Accessing the XML declaration, , Miloslav Nic | Thread | RE: Accessing the XML declaration, , Dylan Walsh |
invoking XT from the command line (, Mike Brown | Date | Re: invoking XT from the command li, TaNiA |
Month |