XSL and QNames

Discussion in 'XML' started by Pieter Vandepitte, Jan 7, 2004.

  1. 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
    Pieter Vandepitte, Jan 7, 2004
    #1
    1. Advertising

  2. In article <>,
    Pieter Vandepitte <> wrote:

    % <?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.
    --

    Patrick TJ McPhee
    East York Canada
    Patrick TJ McPhee, Jan 7, 2004
    #2
    1. Advertising

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

    Patrick TJ McPhee wrote:
    > In article <>,
    > Pieter Vandepitte <> wrote:
    >
    > % <?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.
    Pieter Vandepitte, Jan 8, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Karsten Weinert
    Replies:
    3
    Views:
    1,006
    Karsten Weinert
    Jul 5, 2004
  2. Vijay singh
    Replies:
    1
    Views:
    434
    Martin Honnen
    Nov 4, 2004
  3. David Carlisle

    xsl:import and xsl:apply_import

    David Carlisle, Dec 16, 2004, in forum: XML
    Replies:
    5
    Views:
    490
    Shiju Rajan
    Dec 16, 2004
  4. Replies:
    1
    Views:
    3,598
    A. Bolmarcich
    May 27, 2005
  5. Gleb Alexeev

    Newbie question: QNames in content.

    Gleb Alexeev, Jun 6, 2005, in forum: XML
    Replies:
    6
    Views:
    491
    Gleb Alexeev
    Jun 13, 2005
Loading...

Share This Page