473,748 Members | 10,569 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with namespace and simple query

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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output 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


Jul 20 '05 #1
1 1424

"Howard" <al*****@hotmai l.com> wrote in message
news:Y0******** *************@b gtnsc05-news.ops.worldn et.att.net...
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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output 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:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
xmlns:MYNS=http ://www.w3.org/2000/09/xmldsig#">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<xsl:element name="test1">
<xsl:value-of select="/MYNS:Signature/MYNS:SignatureV alue"/>
</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
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2375
by: Chris | last post by:
Hi all, I have recently started working with the new XML functionality in PHP5, but I am running into a few problems. Specifically, I am using an Xpath query to try and pull out the data in specific elements within my XML file. The problem I am getting is that one of the XML elements contains namespace attributes and this seems to prevent the Xpath query from working (ie, if I manually strip the namespace attributes then the query works...
5
7391
by: Alexander Gnauck | last post by:
Hello, i have problems with the Namespaces and the .Net XML Parser My XML looks like this: <query xmlns="jabber:iq:roster"> <item jid="srlee@localhost" name="srlee" subscription="both"><group>contacts</group></item> <item jid="tlee@localhost" name="Troy" subscription="both"><group>contacts</group></item>
2
2882
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file - "xmlns="http://tempuri.org/nameOfRoot.xsd" I have no idea what its pointing to & what is tempuri.org? So when this tag is in my xml tag my xpath query never works. But when I delete it work fine.
9
9025
by: Richard L Rosenheim | last post by:
I'm trying to query a XML file that was created via ADO.NET. My query wasn't returning anything, and I tracked the problem to an issue with the namespace that ADO.NET specified. When I remove the namespace from the XML data, the query worked. Okay, so I added code to create a XMLNamespaceManager and populate it with the namespace. Now, I'm getting this exception: Prefixes beginning with "xml" (regardless of whether the characters...
8
1999
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid the usage of old style COM, my alternative is to expose my unmanaged interface through the CLI, to achieve that I have created a mixed mode DLL in which my unmanaged class are defined. When referencing the DLL just described in another mixed mode EXE...
1
1873
by: amessimon | last post by:
Hi I'm having a problem querying an XML document using Xquery, i dont know if this is the right place to post, but i couldnt find an xquery newsgroup. Ive also posted in the xml group. Ive not used xquery before and cant find much documentation online regarding the problem i am encountering. Im running the following code, which is a simple query....(ive included all of it as its short and for the sake of completeness).
20
2510
by: Development - multi.art.studio | last post by:
Hello everyone, i just upgraded my old postgres-database from version 7.1 to 7.4.2. i dumped out my 7.1 database (with pg_dump from 7.1) as an sql-file with copy-commands and to one file using insert-statements. after initalizing and starting postgres 7.4 on a different port and datadirectory, i tried to import the sql-dump with the copy statements. this import fails, but importing the dump-file with inserts took a long time but was...
2
2758
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects" and return a complex type "FieldSearchResult". The error message as following : "Cannot assign object of type System.String to an object of type System.String. There is an error in XML document (23, 97)." By the way,I hava written a client in Java...
3
4980
by: Jason Mobarak | last post by:
Hello -- I'm attempting to get a handle on how to do xpath queries with System.Xml -- so far the biggest hurdle has been how to deal with a default namespace. If I use the test xml: <?xml version="1.0" encoding="utf-8" ?> <thing xmlns="urn:thing-schema-v1"> <foo>foo thing</foo> <bar>bar thing</bar>
0
8991
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8244
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3315
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.