Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ged rid off of attributes after XSLT

Status
Not open for further replies.

RaulMA

Programmer
Apr 4, 2006
19
US
XML FILE:

<NewDataSet>
<Table>
<First_Name>Roberto</First_Name>
<Last_Name>Cortez</Last_Name>
<Email>r_cortex@test.com</Email>
<Company_Name>My company</Company_Name>
<Address_1>11 First st</Address_1>
<Address_2>3rd Floor</Address_2>
<City>Indianapolis</City>
<State_>IN</State_>
<Zip>46206</Zip>
<Country>United States</Country>
<Phone>+1 (333) 111-0000</Phone>
<Fax>+1 (333) 999-4444</Fax>
<Title>Mr.</Title>
</Table>
<Table>
<First_Name>Bass</First_Name>
<Last_Name>Alani</Last_Name>
<Email>baltes@toto.com</Email>
<Company_Name>vengalia, Inc.</Company_Name>
<Address_1>20 Bergen</Address_1>
<Address_2>Suite 3000</Address_2>
<City>New York</City>
<State_>NY</State_>
<Zip>10111</Zip>
<Country>United States</Country>
<Phone>+1 (201) 222-9999</Phone>
<Fax>+1 (201) 333-1111</Fax>
<Title>Mr.</Title>
</Table>
</NewDataSet>

XSLT FILE


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl=" xmlns:xs=" xmlns:fn=" xmlns:xdt="<xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:template match="/">
<channel channelType="Admin">

<dealer value="D10"/>
<channel_id>000000</channel_id>
<admin adminId="AAAAAA" feedType="Users">

<xsl:for-each select="NewDataSet/Table">
<person>
<FirstName>
<xsl:value-of select="First_Name"/>
</FirstName>
<Last_Name>
<xsl:value-of select="Last_Name"/>
</Last_Name>
<Email>
<xsl:value-of select="Email"/>
</Email>
<Company_Name>
<xsl:value-of select="Company_Name"/>
</Company_Name>

<xsl:for-each select="Address_1">
<address>
<Address_1>
<xsl:value-of select="Address_1"/>
</Address_1>
<Address_2>
<xsl:value-of select="Address_2"/>
</Address_2>
<City>
<xsl:value-of select="city"/>
</City>
<State>
<xsl:value-of select="State_"/>
</State>
<Zip>
<xsl:value-of select="ZIP"/>
</Zip>
<Country>
<xsl:value-of select="Country"/>
</Country>
</address>
<Phone>
<xsl:value-of select="Phone"/>
</Phone>
</xsl:for-each>

<Title>
<xsl:value-of select="Title"/>
</Title>
</person>
</xsl:for-each>
</admin>
</channel>
</xsl:template>
</xsl:stylesheet>





XML RESULT :

<?xml version="1.0" encoding="UTF-8"?>
<channel xmlns:fn=" xmlns:xdt=" xmlns:xs=" channelType="Admin">
<dealer value="D10"/>
<channel_id>000000</channel_id>
<admin adminId="AAAAAA" feedType="Users">
<person>
<FirstName>Roberto</FirstName>
<Last_Name>Cortez</Last_Name>
<Email>r_cortex@test.com</Email>
<Company_Name>My company</Company_Name>
<address>
<Address_1></Address_1>
<Address_2></Address_2>
<City></City>
<State></State>
<Zip></Zip>
<Country></Country>
</address>
<Phone></Phone>
<Title>Mr.</Title>
</person>
<person>
<FirstName>Bass</FirstName>
<Last_Name>Alani</Last_Name>
<Email>baltes@toto.com</Email>
<Company_Name>vengalia, Inc.</Company_Name>
<address>
<Address_1></Address_1>
<Address_2></Address_2>
<City></City>
<State></State>
<Zip></Zip>
<Country></Country>
</address>
<Phone></Phone>
<Title>Mr.</Title>
</person>
</admin>
</channel>



The xml out put is almost perfect however on the channel elememt additional attributes are included I really dont know how to get rid off them and obtain something like this:


<?xml version="1.0" encoding="UTF-8"?>
<channel channelType="Admin">
..............THE REST OF THE NODES
</channel>
 
Since you don't seem to need those additional namespace declarations change your xsl:stylesheet element to:
Code:
<xsl:stylesheet version="2.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]

Tom Morrison
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top