how to reference data when a node has a XMLNS pointing to a DTD?

Discussion in 'XML' started by Andy, Apr 26, 2005.

  1. Andy

    Andy Guest

    OK, I'm not sure what I'm missing here.

    I'm working with this XML:

    <?xml version="1.0" encoding="utf-8"?>
    <GroupDataBlock xmlns="http://www.acme.com/data.dtd">
    <GroupInfo>
    <ProgramID>3002616</ProgramID>
    </GroupInfo>
    </GroupDataBlock>

    and this XSL:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="/">
    <xsl:value-of select="GroupDataBlock/GroupInfo/ProgramID" /><br />
    </xsl:template>
    </xsl:stylesheet>

    Any idea why it won't show the ProgramID value?

    Is there something in the DTD that I need to know to display this
    correctly? Isn't the GroupInfo nested within the GroupDataBlock node?

    Any help would be much appreciated.

    Thanks,
    Andy
    Andy, Apr 26, 2005
    #1
    1. Advertising

  2. Namespace declarations in xmlns don't really "point to" anything, the
    URI is just a string identifying the namespace, it is never "looked up"

    This is a FAQ. (see the faq for xsl-list for example)

    "Andy" <> writes:

    > OK, I'm not sure what I'm missing here.
    >
    > I'm working with this XML:
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <GroupDataBlock xmlns="http://www.acme.com/data.dtd">


    so that is the element with name consisting of local name
    GroupDataBlock
    and namespace
    http://www.acme.com/data.dtd
    (it's unusual to use a dtd uri as a namespace, but anything would do,
    xmlns="data:,hello"
    for example.) The Processor will not look at the dtd file anyway.


    > <xsl:value-of select="GroupDataBlock/GroupInfo/ProgramID" />


    that selects an element GroupDataBlock in no-namespace (and similarly
    GroupInfo and ProgramID

    add xmlns:x="http://www.acme.com/data.dtd" to your xsl:stylesheet
    element so x: is in scope for the whole stylesheet then you can use

    <xsl:value-of select="x:GroupDataBlock/x:GroupInfo/x:programID" />

    to select elements from this namespace.

    David
    David Carlisle, Apr 26, 2005
    #2
    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. Replies:
    0
    Views:
    1,399
  2. Replies:
    0
    Views:
    1,324
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,399
    Dimitre Novatchev
    Aug 24, 2006
  4. Replies:
    16
    Views:
    582
    Jim Langston
    Oct 7, 2006
  5. afshar
    Replies:
    3
    Views:
    24,152
    aljar
    May 19, 2010
Loading...

Share This Page