XSL and QNames

  • Thread starter Pieter Vandepitte
  • Start date
P

Pieter Vandepitte

Hi,
i have an xml document like this:

<?xml version="1.0"?>
<qname:element id="blabla" xmlns:qname="http://myblabla.com">
<qname:child>My text</qname:child>
</qname:element>

[remark: i'm using QNames in my xml document]

Suppose i want to get the attribute 'id' from qname:element and the
value of the qname:child node, how should i do this with xsl?

i thought it would work just like other stylesheets, without taking into
account the qname, but it didn't work :(

Anyone a solution?

w.Kind regards
Pieter
 
P

Patrick TJ McPhee

% <?xml version="1.0"?>
% <qname:element id="blabla" xmlns:qname="http://myblabla.com">
% <qname:child>My text</qname:child>
% </qname:element>

% [remark: i'm using QNames in my xml document]

A QName is a combination of a name space and an element name. In your
example, `qname' is a name space prefix while qname:child is a QName.

% Suppose i want to get the attribute 'id' from qname:element and the
% value of the qname:child node, how should i do this with xsl?

You need to define a name space prefix in the stylesheet. For instance

<xsl:value-of select="bla:element/@id" xmlns:bla='http://myblabla.com'/>

You can, of course, define the name space prefix at a higher level.

It's worth mentioning that you must use a name space prefix in the
stylesheet, even if you use a default name space in your xml document.
 
P

Pieter Vandepitte

thanx!! i was forgotten an xsl document IS an xml document, in which you
can use an xmlns 'name space prefix' ;)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top