Subject: RE: [xsl] Namespace related question From: "Michael Kay" <mhk@xxxxxxxxx> Date: Sun, 13 Jul 2003 09:36:10 +0100 |
> I am a novice and struggling for last few days to get the solution. > > here is sample xml document, I want to read the value of > attribute xmlns.Res > using XSL stylesheet > > <PT xmlns.Res="PT_MSG"> > .... > </PT> I assume you mean xmlns:Res="PT_MSG"? (":" not ".")? Namespace declarations are not attributes in the XPath data model. A namespace declaration in your source document translates into a namespace node in the data model, and must be read using the namespace axis rather than the attribute axis. So you can access it as namespace::Res. But it would be nicer to show us the whole problem you are tackling: people will probably have comments at the design level. Explicit access to namespace nodes is not a common requirement and I wouldn't normally expect a novice to need to do it. There is probably an easier way of solving your problem. Michael Kay > > here's my stylesheet > <?xml version="1.0"?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:output method="html" indent="yes" /> > > <xsl:template match="HFPT" > xmlns="http://www.w3.org/XML/1998/namespace"> > <xsl:copy-of select="@xmlns:Res" /> > </xsl:template> > > </xsl:stylesheet> > > I tried <xsl:copy-of select="@xmlns:Res" />, I got error > message - "Namespace prefix xmlns has not been declared". > > So how can I do it in XSL ? > > Any solution will be appreciated. > > Thanks > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Namespace related question, sumit | Thread | [xsl] how to read attribute if defi, sumit |
[xsl] Re: Detecting the tags inside, Dimitre Novatchev | Date | RE: [xsl] Detecting the tags inside, Michael Kay |
Month |