473,585 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XSLT problem -- namespace issue?

Here's a sample XML file (created by saving a dataset):

<?xml version "1.0" standalone="yes "?>
<dsData xmlns="http://tempuri.org/DataSchema.xsd" >
<Configuratio n>
</Configuration>
<Data>
<ID>0</ID>
<Title>Test #1</Title>
</Data>
<Data>
<ID>1</ID>
<Title>Test #2</Title>
</Data>
</dsData>

And my XSLT style sheet:

<xsl:styleshe et xmls:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:my="http://my.com">
<my:Parameter >
<name value="value1" />
<name value="value2" />
</my:Parameter>

<xsl:output method="html" />
<xsl:template match="*">
<html>
<body>
<table>
Sample Table
<xsl:for-each select="Data" >
<tr>
<td>Title:</td>
<td><xsl:valu e-of select="Title" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

My problem is when the attribute xmlns="http://tempuri.org/DataSchema.xsd"
is in the XML file, the data is not included in the output when I do the
transformation. If, I remove the attribute, everything works fine.
Therefore, I'm suspecting I might need to specify the namespace somewhere,
somehow.

But, I've been unable to find any such examples of how to do that. I'm
using the book "XSLT 2nd Edition" by Michael Kay. I also searched the web a
little to no avail.

Can someone help me out here?

TIA,

Richard Rosenheim
Nov 12 '05 #1
4 1413
I tried changing your XSL file to this:

<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:my="http://my.com"
xmlns:in="http://tempuri.org/DataSchema.xsd" >
<my:Parameter >
<name value="value1" />
<name value="value2" />
</my:Parameter>
<xsl:output method="html" />
<xsl:template match="/in:dsData">
<html>
<body>
<table>
Sample Table
<xsl:for-each select="in:Data " >
<tr>
<td>Title:</td>
<td><xsl:valu e-of select="in:Titl e"
/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

and now I get data.

Also, in future please paste the actual XML and XSL test documents into
your post. The post had some typos that made it malformed... they
couldn't be the actual documents you were testing with. It's easier and
quicker to solve your problem if we don't have to fix syntax errors
first.... :)

Nov 12 '05 #2
Thank you -- it's very much appreciated.

I'm gathering from your changes that basically I can have as many
xmlns:<anything > as I basically need.

I did a Google search on xmlns, and checked a number of what appeared to be
promising web sites (like http://www.w3.org/TR/xptr-xmlns/,
http://www.faqts.com/knowledge_base/...html/aid/24224 and
http://www.jclark.com/xml/xmlns.htm). Didn't find anything that was
helpful. Nor does my 939 page XLST book even have an entry in the index for
xmlns...

Do you happen to know of a book you care to recommend?

Richard Rosenheim
"Bruce Wood" <br*******@cana da.com> wrote in message
news:11******** **************@ l41g2000cwc.goo glegroups.com.. .
I tried changing your XSL file to this:

<xsl:styleshe et xmlns:xsl="http ://www.w3.org/1999/XSL/Transform"
version="1.0" xmlns:my="http://my.com"
xmlns:in="http://tempuri.org/DataSchema.xsd" >
<my:Parameter >
<name value="value1" />
<name value="value2" />
</my:Parameter>
<xsl:output method="html" />
<xsl:template match="/in:dsData">
<html>
<body>
<table>
Sample Table
<xsl:for-each select="in:Data " >
<tr>
<td>Title:</td>
<td><xsl:valu e-of select="in:Titl e"
/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

and now I get data.

Nov 12 '05 #3
I usually get most of my information off the Web.

You want to search for "XML" and "namespaces ". This is what I came up
with:

1. The W3C document is a bit opaque, but they do define the thing, so:

http://www.w3.org/TR/REC-xml-names/

2. Google found me a few more accessible write-ups:

http://www.xml.com/pub/a/1999/01/namespaces.html

http://www.w3schools.com/xml/xml_namespaces.asp

http://www-106.ibm.com/developerwork...x-nmspace.html

http://www.rpbourret.com/xml/NamespacesFAQ.htm

Nov 12 '05 #4
Thanks again. I'll take at look at the links.

Richard Rosenheim
"Bruce Wood" <br*******@cana da.com> wrote in message
news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
I usually get most of my information off the Web.

You want to search for "XML" and "namespaces ". This is what I came up
with:

1. The W3C document is a bit opaque, but they do define the thing, so:

http://www.w3.org/TR/REC-xml-names/

2. Google found me a few more accessible write-ups:

http://www.xml.com/pub/a/1999/01/namespaces.html

http://www.w3schools.com/xml/xml_namespaces.asp

http://www-106.ibm.com/developerwork...x-nmspace.html

http://www.rpbourret.com/xml/NamespacesFAQ.htm

Nov 12 '05 #5

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

Similar topics

1
1670
by: Harry Zoroc | last post by:
I would like to treat an xsd Schema file as XML file and to display the targetNamespace and all the imports. That's it. But the following does not work. Why? I did not enter the stylesheet in the xsd file directly but tried to compute the output on the command line e.g. with xalan like: java net.sf.saxon.Transform -o myout.html...
4
8112
by: cyclops | last post by:
I'm trying to do XML + XSLT -> Another XML. The source XML contains multiple namespaces and XSLT will handle all possible tags under each name space. ----source---- <document xmlns="..." xmlns:a="..." xmlns:b=""> .... ----XSLT---- ....
6
3230
by: Christopher | last post by:
I am currently in the process of evaluating the performance hits of moving to the .NET platform for our application. I created a sample project that loads the transforms the same XML and XSLT in COM, COM using interop and in C# and then transforms it to HTML. I also tried concatenating the XML and XSL as a string and then loading it to the DOM...
1
2733
by: Nick | last post by:
I am working on a website for a client and one of their requirements was to have a mailing list. I decided to XSLT to transform "templates" to HTML so that editing was very easy and less time consuming. I keep getting the following error when I submit my email to their site. System.Xml.Xsl.XslTransformException: Cannot find the script or...
1
1879
by: Rajesh | last post by:
I am trying to pass the namespace, which is in my Original Message, to a Java method for further processing. In the original message the xmlns:xenc namespace is present. I make a call to Java function and pass the whole XML message along with tags and values. In my Java function when I tried to print the XML message which is receieved by the...
10
3583
by: Andy Fish | last post by:
hi, I have an XSLT which is producing XML output. many of the nodes in the output tree contain namespace declarations for namespaces that are used in the source document even though they are not used in the result document or the stylesheet also I find that (for namespaces that are referenced in the stylesheet) even if I put an...
4
4328
by: pc.candy | last post by:
Hi there I'm having some difficulty with transforming xml data with more than one namespace defined in the xml. I'm able to bring back some values of the xml but not others in another namespace? For example from the following xml data I can bring bring back the value for <addressbut I can't seem to figure out how to bring back the...
6
4331
by: kluge.wolfram | last post by:
Hi, i get stucked on a transformation problem using XSLT. What i need is to copy an XML Tree to an output XML without any automatic changes. Since i used <xsl:copyor <xsl:copy-ofthere occur unwanted side effects. For example i just copied a xml were several namespace declarations are present more than one time. Then the transformation do...
0
7836
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8199
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. ...
0
8212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6606
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...
0
5389
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3835
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...
0
3863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1447
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1175
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...

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.