problem with namespace and simple query

H

Howard

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
 
H

Howard

Howard said:
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
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top