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
Mayank MariaSubject: Prefix Namespace Collision
Author: Mayank Maria
Date: 25 Dec 2006 08:13 AM
Originally Posted: 25 Dec 2006 03:32 AM
Hi

I have a source xml which is as follows.

<abc:RootElement xmlns:abc="http://www.xxxxx.xxx">
<abc:FirstElement>
<xyz:NewElement xmlns:xyz="http://www.yyyyy.yyy">
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
</xyz:NewElement>
<xyz:NewElement xmlns:xyz="http://www.yyyyy.yyy">
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
</xyz:NewElement>
</abc:FirstElement>
<abc:FirstElement>
<xyz:NewElement xmlns:xyz="http://www.yyyyy.yyy">
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
</xyz:NewElement>
<xyz:NewElement xmlns:xyz="http://www.yyyyy.yyy">
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
<abc:SecondElement xmlns:xyz="http://www.yyyyy.yyy" xyz:usage="Required">
<abc:ThirdElement>End</abc:ThirdElement>
</abc:SecondElement>
</xyz:NewElement>
</abc:FirstElement>
</abc:RootElement>

I need to loop through each of the <xyz:NewElement/> tag and also each of the <abc:SecondElement/> tag.

Thus i try to use two <xsl:for-each/> tags one on <xyz:NewElement/> and other on <abc:SecondElement/>. But the problem is i am not able to loop through the <abc:SecondElement/> tag.
i.e
My xslt is as follows.
<xsl:for-each select="abc:RootElement/abc:FirstElement/xyz:NewElement">
<xsl:for-each select=""> <!-- Not able to get any of the sub elements of xyz:NewElement tag -->

</xsl:for-each>
</xsl:for-each>

even

<xsl:value-of select="abc:RootElement/abc:FirstElement/xyz:NewElement/abc:SecondElement"/>

is not working.

Let me know how i can solve this prefix collision.

Have also attached the sample .xml and .xsl files

Thanks in Advance.


Documenttest(15).xml
Sample XML

Documenttestxslt.xsl
Sample XSL

Postnext
Minollo I.Subject: Prefix Namespace Collision
Author: Minollo I.
Date: 25 Dec 2006 11:23 PM
...I guess you are just not specifying the XPath expession for the second for-each? This seems to work fine for me using your XML source:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:abc="http://www.xxxxx.xxx"
xmlns:xyz="http://www.yyyyy.yyy">

<xsl:template match="/">
<xsl:for-each select="abc:RootElement/abc:FirstElement/xyz:NewElement">
<xyzNewElement>
<xsl:for-each select="abc:SecondElement">
<abcSecondElement/>
</xsl:for-each>
</xyzNewElement>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Posttop
Mayank MariaSubject: Prefix Namespace Collision
Author: Mayank Maria
Date: 26 Dec 2006 03:55 AM
Originally Posted: 26 Dec 2006 12:31 AM
Thanks with that help i found out the answer..
The xml namespace which i was using was older one..
i just corrected out that and it worked.

Thanks for the solution.

 
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.