problem with namespace and simple query

Discussion in 'XML' started by Howard, Feb 4, 2005.

  1. Howard

    Howard Guest

    Hi,

    I am using a very simple xslt file to get info from an xml document.
    The problem seems to me to be that the xml doc uses a namespace, and I don't
    know how to set up my xslt to recognize it correctly. If I remove the
    namespace specification from the xml, I can query the node I want perfectly.
    But with that namespace in there, it fails. Can someone help?

    Here's a simpilified version of the xml document, with that namespace stuff:

    <?xml version="1.0" encoding="UTF-8"?>
    <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
    some stuff I don't care about
    </SIgnedInfo>
    <SignatureValue>
    the stuff I want
    </SignatureValue>
    </Signature>

    and here's my xslt file:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <xsl:element name="test1">
    <xsl:value-of select="/Signature/SignatureValue"/>
    </xsl:element>
    </xsl:template>
    </xsl:stylesheet>

    If I remove that xmlns part of the xml (which isn't really an option when
    trying to use the real file), it works fine. But as it is above, it gives
    me nothing. I'm pretty sure I have to specify the namespace somehow in the
    xslt, but how, and where?

    Thanks much,
    Howard
     
    Howard, Feb 4, 2005
    #1
    1. Advertising

  2. Howard

    Howard Guest

    "Howard" <> wrote in message
    news:Y0PMd.149934$...
    > Hi,
    >
    > I am using a very simple xslt file to get info from an xml document.
    > The problem seems to me to be that the xml doc uses a namespace, and I
    > don't know how to set up my xslt to recognize it correctly. If I remove
    > the namespace specification from the xml, I can query the node I want
    > perfectly. But with that namespace in there, it fails. Can someone help?
    >
    > Here's a simpilified version of the xml document, with that namespace
    > stuff:
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    > <SignedInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
    > some stuff I don't care about
    > </SIgnedInfo>
    > <SignatureValue>
    > the stuff I want
    > </SignatureValue>
    > </Signature>
    >
    > and here's my xslt file:
    >
    > <?xml version="1.0" encoding="UTF-8"?>
    > <xsl:stylesheet version="1.0"
    > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    > <xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    > <xsl:template match="/">
    > <xsl:element name="test1">
    > <xsl:value-of select="/Signature/SignatureValue"/>
    > </xsl:element>
    > </xsl:template>
    > </xsl:stylesheet>
    >


    Never mind! I found the answer in another posting here (should have looked
    first!). I changed the xslt to this, and it worked:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:MYNS=http://www.w3.org/2000/09/xmldsig#">
    <xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:template match="/">
    <xsl:element name="test1">
    <xsl:value-of select="/MYNS:Signature/MYNS:SignatureValue"/>
    </xsl:element>
    </xsl:template>
    </xsl:stylesheet>


    Thanks anyway (esp. to those who've answered this for others, so that I
    could find the answer myself!)

    -Howard
     
    Howard, Feb 4, 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:
    1
    Views:
    599
    William F. Robertson, Jr.
    Jul 29, 2003
  2. Replies:
    0
    Views:
    5,167
  3. Anonymous
    Replies:
    3
    Views:
    561
    Ron Natalie
    Aug 18, 2003
  4. Jason Heyes
    Replies:
    1
    Views:
    469
    Woebegone
    Nov 19, 2004
  5. Petter Reinholdtsen
    Replies:
    9
    Views:
    4,435
    Howard
    Nov 29, 2004
Loading...

Share This Page