Swarup Sathe

Greenhorn
+ Follow
since Aug 04, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Swarup Sathe

Hi Everyone,
I am also interested in embedding voice XML and like to participate in this forum.
Welcome Jeff and thanks for sharing the knowledge with us.
Regards,
Swarup
Hi All,
I have a XSLT code which works fine and it is as follows :
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="/">
<PERIODIC_TABLE><xsl:apply-templates/></PERIODIC_TABLE>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/node()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/ATOM[NAME='Swarup']">
<xsl:element name="ATOM">
<xsl:copy-of select="@*"/>
<xsl:copy-of select="node()"/>

<xsl:element name="NAME">
<xsl:attribute name="b">x</xsl:attribute>Swap</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Now on the same lines if i use this code IT DOES NOT WORK as the DEPTH (i.e company/companyDetails/classificationInfo) increases it gives problem....
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="/">
<company><xsl:apply-templates/></company>
</xsl:template>
<xsl:template match="company/node()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="company/companyDetails/classificationInfo[naics='333412']">
<xsl:element name="classificationInfo">
<xsl:copy-of select="@*"/>
<xsl:copy-of select="node()"/>

<xsl:element name="naics">
<xsl:attribute name="naics">007</xsl:attribute>77777</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Thanks in Advance...
Hi,
I found out a better solution based on your input..
The XSL is as follows :
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="/">
<PERIODIC_TABLE><xsl:apply-templates/></PERIODIC_TABLE>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/node()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/ATOM[not(MELTING_POINT)]">
<xsl:element name="ATOM">
<xsl:copy-of select="@*"/>
<xsl:copy-of select="node()"/>

<xsl:element name="MELTING_POINT">
<xsl:attribute name="UNITS">Kelvin</xsl:attribute>0.00</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
Tell me what do you think about it.
Thanks
Swarup
Hi,
Thanks for the reply. I tried the example but it did not work..
XML file:
<?xml version="1.0"?>
<PERIODIC_TABLE>
<ATOM STATE="GAS">
<NAME>Hydrogen</NAME>
<SYMBOL>H</SYMBOL>
<ATOMIC_NUMBER>1</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>1.00794</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">20.28</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">13.81</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter">
<!-- At 300K, 1 atm -->
0.0000899
</DENSITY>
</ATOM>
<ATOM STATE="GAS">
<NAME>Helium</NAME>
<SYMBOL>He</SYMBOL>
<ATOMIC_NUMBER>2</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>4.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">4.216</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">0.95</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter"><!-- At 300K -->
0.0001785
</DENSITY>
</ATOM>
<ATOM STATE="GAS">
<NAME>Swarup</NAME>
<SYMBOL>Sw</SYMBOL>
<ATOMIC_NUMBER>7</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>7.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">7.216</BOILING_POINT>
<DENSITY UNITS="grams/cubic centimeter"><!-- At 300K -->
7.0001785
</DENSITY>
</ATOM>
</PERIODIC_TABLE>
XSL File:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl utput method="xml" indent="yes"/>

<xsl:template match="/">
<PERIODIC_TABLE><xsl:apply-templates/></PERIODIC_TABLE>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/node()">
<xsl:copy-of select="."/>
</xsl:template>
<xsl:template match="PERIODIC_TABLE/ATOM/MELTING_POINT">
<ATOM>contentx</ATOM>
</xsl:template>
</xsl:stylesheet>
Output XML File:
<?xml version="1.0" encoding="UTF-8"?>
<PERIODIC_TABLE>
<ATOM STATE="GAS">
<NAME>Hydrogen</NAME>
<SYMBOL>H</SYMBOL>
<ATOMIC_NUMBER>1</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>1.00794</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">20.28</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">13.81</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter">
<!-- At 300K, 1 atm -->
0.0000899
</DENSITY>
</ATOM>
<ATOM STATE="GAS">
<NAME>Helium</NAME>
<SYMBOL>He</SYMBOL>
<ATOMIC_NUMBER>2</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>4.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">4.216</BOILING_POINT>
<MELTING_POINT UNITS="Kelvin">0.95</MELTING_POINT>
<DENSITY UNITS="grams/cubic centimeter">
<!-- At 300K -->
0.0001785
</DENSITY>
</ATOM>
<ATOM STATE="GAS">
<NAME>Swarup</NAME>
<SYMBOL>Sw</SYMBOL>
<ATOMIC_NUMBER>7</ATOMIC_NUMBER>
<ATOMIC_WEIGHT>7.0026</ATOMIC_WEIGHT>
<BOILING_POINT UNITS="Kelvin">7.216</BOILING_POINT>
<DENSITY UNITS="grams/cubic centimeter">
<!-- At 300K -->
7.0001785
</DENSITY>
</ATOM>
</PERIODIC_TABLE>

Here I want to remove the element which does not have the MELTING-POINT Tag in it.
Thanks..
------------------
Hi,
Thanks a lot for your reply. But can you please give me an example where there are lots of elements and nodes in the XML. How should the "copy-of select" statement work in that case.
<xsl:template match="title">
<xsl:copy-of select="*"/>
</xsl:template>

<root>
<element1 id="1">content1
<element2>content2</element2>
</element1>
<element3>content3</element3>
</root>
<xsl:template match="element1">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
The example you gave was for a small XML consider an example like this one..
<root>
<element1 id="1">content1
<element2>content2</element2>
</element1>
<element2 id="2">content2
<element2>content2</element2>
</element2>
<element3 id="3">content3
<element3>content3</element3>
</element3>
<element4 id="4">content4
<element4>content4</element4>
</element4>
<element5 id="5">content5
<element5>content5</element5>
</element5>
<element6>content6</element6>
</root>
how would u write the XSLT .....
3. Updating..
Updating a tag will be on the same lines as delete and add. So i will delete a particular element and then insert same element with different value.. Consider the following..
<element6>content6</element6>
Now I want to update the value with comtentx
I will delete the whole tag and insert a tag <element6>contentx</element6>
So what will be the XSLT code for it considering the above big XML.

My output will be again XML ONLY.
Thanks
Swarup

------------------
Hi XML Gurus,
Need some help on XML tranformation using XSLT. I need help on coding the XSL for the requirement.I have a requirement where there are around 10 XML files where one has to Update,Delete, and insert elements in the XML document keeping the other nodes and information intact. So the input is an XML file, XSLT is used to process the document where it will update, delete, insert a elements and output is an XML document similiar to the input XML with slight changes in the elements.
I have read few documents and experimented a bit...
For copying we have code..
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="title">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
OR
<xsl:template match="title">
<xsl:copy-of select="*"/>
</xsl:template>
For Deleting:
<xsl:template match="nickname">
</xsl:template>
<xsl:template match="project[@status='canceled']">
</xsl:template>
For Updating :
<xsl:template match="article">
<html>
<xsl:apply-templates/>
</html>
</xsl:template>
If anyone has better ideas.Please let me know..
Thanks for the help in advance.
Regards
Swarup

------------------