473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

how do I find out the namespace of a node??

45
Hi all I have a XML file and I am trying to transform and create another XML file using the XSLT. I need to check a particular node belongs to a specific namespace or not. How do I do it in the .xsl file??

many thanks.
Jun 27 '07 #1
3 1809
Dököll
2,364 Expert 2GB
Hi all I have a XML file and I am trying to transform and create another XML file using the XSLT. I need to check a particular node belongs to a specific namespace or not. How do I do it in the .xsl file??

many thanks.
Greetings, querry!

Google fetch results at your disposal for the time being. If they do not work, please write and stay tuned:

http://www.google.com/search?hl=en&q...=Google+Search

In a bit!
Jun 28 '07 #2
querry
45
Greetings, querry!

Google fetch results at your disposal for the time being. If they do not work, please write and stay tuned:

http://www.google.com/search?hl=en&q...=Google+Search

In a bit!
My Problem was this... (go to the last post on this page http://www.thescripts.com/forum/thread648612.html)


I tried this and it worked

[HTML]
<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="http://something.com/ns1">



<xsl:output method="xml" indent="yes" encoding="utf-8" omit-xml-declaration="yes"/>


<xsl:template match="/">

<xsl:for-each select="//Table">

<HTML>

<HEAD><TITLE>Some Title</TITLE></HEAD>

<TABLE>

<xsl:apply-templates select="TR"/>

</TABLE>

</HTML>

</xsl:for-each>

</xsl:template>


<xsl:template match="/ns1:TR">

<TR>

<xsl:apply-templates select="TD"/>

</TR>

</xsl:template>


<xsl:template match="/ns1:TD">

<TD>

Some thing.......

</TD>

</xsl:template>

</xsl:stylesheet>[/HTML]

And if you have something like this....


[HTML]<ns1:Table xmlns:ns1="http://something.com/ns1" xmlns:ns2="http://something.com/ns2">

<ns1:TR>

<ns1:TD >some text </ns1:TD>

<ns1:TD >some text </ns1:TD>

<ns2:TD >some text </ns1:TD>

<ns2:TD >some text </ns1:TD>

</ns1:TR>

</ns1:Table>[/HTML]

Then modify the code in xsl file like this...

[HTML]<xsl:template match="/nsl:TR">

<xsl:choose>
<xsl:when test="self::ns1:TR/ns1:TD">
<xsl:apply-templates select="ns1:TD"/>
</xsl:When>
</xsl:choose>
<xsl:choose>
<xsl:when test="self::ns1:TR/ns2:TD">
<xsl:apply-templates select="ns2:TD"/>
</xsl:when>
</xsl:choose>

</xsl:template>[/HTML]

cerate two seperate templates for the TD's of different namespaces.

Hope it will help the others.
Jul 5 '07 #3
Dököll
2,364 Expert 2GB
Alright, querry!

Good of you to post what worked, sorry the link did not help...

Have a great end to your work week!
Jul 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: wooks | last post by:
I want to apply 2 changes to the following xml <ROOTSTUB app="appname"/> 1. change the app attribute to an element. 2. put the ROOTSTUB element into a namespace that is passed as a global...
5
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"...
2
by: Michal Januszczyk | last post by:
I have a very simple XML document. <SmtpGatewayRules xmlns="http://www.foo.com/schema.xsd"> <rules> <rule> </rule> </rules> </SmtpGatewayRules> When no xmlns is specified I can find rule...
6
by: David B. Bitton | last post by:
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribute with a namespace defined. If I attempt to deserialize the XML, I get...
6
by: Nikhil Patel | last post by:
Hi all, Following is a portion of an XML document. I need to remove all nodes that belong to ns0 without deleting their child nodes. So in the following example , I want to delete "ns0:Proposal"...
8
by: Simon Brooke | last post by:
I was debugging a new XML generator tonight and trying to determine why it wasn't working; and realised my dom printer does not output XML namespace declarations. My method to output an Element...
4
by: XML newbie: Urgent pls help! | last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it verifies the login information it should display the SessionID and enable some button . I appreciate your help and thanku...
16
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument...
10
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...
2
by: slizorn | last post by:
hi guys, i need to make a tree traversal algorithm that would help me search the tree.. creating a method to search a tree to find the position of node and to return its pointer value basically i...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.