XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
amith swamySubject: Regarding XML namespace prefix in input xml for XSL transformation
Author: amith swamy
Date: 15 Nov 2007 05:12 AM
Hi,

We are trying to do XML-XML conversion using XSL

Our sample input XML just has namespace but doesnt has namespace prefix.

<?xml version="1.0"?>
<root xmlns = "http://www.w3.org/2001/XMLSchema-instance">
<name>ABC</name>
<id>12</id>
<desg>SE</desg>
</root>

The XSL used to do conversion is
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<root xmlns:p1="http://www.w3.org/2001/XMLSchema-instance">
<Companyname>
<xsl:value-of select="root/name"/>
</Companyname>
<Companyid>
<xsl:value-of select="root/id"/>
</Companyid>
<Empdesg>
<xsl:value-of select="root/desg"/>
</Empdesg>
</root>
</xsl:template>
</xsl:stylesheet>

But the output xml is empty.

But if we have namespace prefix in smaple input as below, we get proper output.
<?xml version="1.0"?>
<root xmlns:p1 = "http://www.w3.org/2001/XMLSchema-instance">
<Companyname>String</Companyname>
<Companyid>12</Companyid>
<Empdesg>Str</Empdesg>
</root>

The problem is that our application will not generate namespace prefix and hence our output is empty.
Please let us know how this can be solved so that we get the output if our input xml doesnt has namespace prefix.

Postnext
(Deleted User) Subject: Regarding XML namespace prefix in input xml for XSL transformation
Author: (Deleted User)
Date: 15 Nov 2007 08:24 AM
Hi Amith,
if the input XML has a xmlns="..." attribute, it means that the elements are in that namespace (even if I find strange that the namespace is a reserved one, usually associated with the xsi prefix), so you should write the XPath queries as p1:root/p1:xxxx

Hope this helps,
Alberto

Postnext
amith swamySubject: Regarding XML namespace prefix in input xml for XSL transformation ---- updated
Author: amith swamy
Date: 15 Nov 2007 10:10 AM
Hi,

Thank you for the updates.

Here we cannot change input xml and it has xmlns without prefix
<root xmlns = "http://www.w3.org/2001/XMLSchema-instance">

Let us know wether it is a bug with the XML and it should be changed for XSL to work?
If this problem can be solved without changing the input xml, let us know how can we do it in the XSL.
Even if we specify XPath queries as p1:root/p1:xxxx, our input xml doesnt has p1 prefix only.

As we are pretty new to XSL, please help us in updating the XSL so that we get the output

Posttop
James DurningSubject: Regarding XML namespace prefix in input xml for XSL transformation ---- updated
Author: James Durning
Date: 15 Nov 2007 12:02 PM
It doesn't matter what the prefix is in the source xml, as long as the namespace matches. You can change the prefix in your xsl to anything you want.

Rewrite the xpaths as suggested above and it will work.

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.