Click here to Skip to main content
15,887,405 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: XML? Pin
Rahithi18-Jan-07 13:36
Rahithi18-Jan-07 13:36 
GeneralRe: XML? Pin
George L. Jackson18-Jan-07 13:50
George L. Jackson18-Jan-07 13:50 
GeneralRe: XML? Pin
Rahithi18-Jan-07 15:05
Rahithi18-Jan-07 15:05 
GeneralRe: XML? Pin
shakhtyor20-Jan-07 16:03
shakhtyor20-Jan-07 16:03 
GeneralRe: XML? Pin
Rahithi20-Jan-07 17:49
Rahithi20-Jan-07 17:49 
GeneralRe: XML? Pin
shakhtyor20-Jan-07 20:37
shakhtyor20-Jan-07 20:37 
GeneralRe: XML? Pin
Rahithi21-Jan-07 4:06
Rahithi21-Jan-07 4:06 
QuestionXSL general question Pin
picazo17-Jan-07 11:49
picazo17-Jan-07 11:49 
Hi,

I am new to XSL and I was hoping someone could help me with a problem I am having.

I have an Input.xml file to which I want to apply a xsl stylesheet Style.xsl. I also have a Template.xml file which I want to use as the base for the output file.

At the moment, here is what I have:

<!-- Input.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<InputRoot>
<elem name="a" AttName='11'></elem>
<elem name="b" AttName='22'></elem>
<elem name="c" AttName='33'></elem>
<elem name="d" AttName='44'></elem>
<elem name="e" AttName='55'></elem>
<elem name="f" AttName='66'></elem>
</InputRoot>

<!-- Template.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<TemplateRoot>
<elem name="a" AttName='Ones'></elem>
<elem name="b" AttName='Twos'></elem>
<elem name="c" AttName='Threes'></elem>
<elem name="d" AttName='Fours'></elem>
<elem name="e" AttName='Fives'></elem>
<elem name="f" AttName='Sixes'></elem>
</TemplateRoot>

<!-- Style.xsl -->
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>

<xsl:variable name="Template" select="document('Template.xml')"/>

<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>

<xsl:template match="elem">
<xsl:variable name="iden" select="@name"/>
<xsl:variable name="attrVal" select="@AttName"/>
<xsl:variable name="newAttrName" select="$Template/TemplateRoot/elem[@name =$iden]/@AttName"/>

<xsl:element name="elem">
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="{$newAttrName}">
<xsl:value-of select="$attrVal" />
</xsl:attribute>
</xsl:element>
</xsl:template>
</xsl:stylesheet>

<!-- Output.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<InputRoot>
<elem name="a" Ones="11"/>
<elem name="b" Twos="22"/>
<elem name="c" Threes="33"/>
<elem name="d" Fours="44"/>
<elem name="e" Fives="55"/>
<elem name="f" Sixes="66"/>
</InputRoot>

I seem to be doing this backwards, here is what I want
<!-- Desired Output.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<TemplateRoot>
<elem name="a" Ones="11"/>
<elem name="b" Twos="22"/>
<elem name="c" Threes="33"/>
<elem name="d" Fours="44"/>
<elem name="e" Fives="55"/>
<elem name="f" Sixes="66"/>
</TemplateRoot>

Any help would be greatly appreciated

-----------------
Genaro
AnswerRe: XSL general question Pin
led mike18-Jan-07 5:12
led mike18-Jan-07 5:12 
AnswerRe: XSL general question Pin
Dustin Metzgar18-Jan-07 7:08
Dustin Metzgar18-Jan-07 7:08 
GeneralAdvice on Standard Message Wrapper Pin
Brady Kelly17-Jan-07 2:02
Brady Kelly17-Jan-07 2:02 
GeneralRe: Advice on Standard Message Wrapper Pin
Stefan Troschuetz17-Jan-07 4:26
Stefan Troschuetz17-Jan-07 4:26 
GeneralRe: Advice on Standard Message Wrapper Pin
led mike17-Jan-07 6:37
led mike17-Jan-07 6:37 
Questionaltering data of embeded xml file in assembly Pin
vishwa2514-Jan-07 21:48
vishwa2514-Jan-07 21:48 
GeneralRe: altering data of embeded xml file in assembly Pin
George L. Jackson15-Jan-07 3:10
George L. Jackson15-Jan-07 3:10 
AnswerRe: altering data of embeded xml file in assembly Pin
Ed.Poore15-Jan-07 5:03
Ed.Poore15-Jan-07 5:03 
QuestionTurning an xml string held in a single excel cell into an XML document Pin
alect14-Jan-07 8:51
alect14-Jan-07 8:51 
AnswerRe: Turning an xml string held in a single excel cell into an XML document Pin
George L. Jackson15-Jan-07 3:15
George L. Jackson15-Jan-07 3:15 
GeneralRe: Turning an xml string held in a single excel cell into an XML document Pin
alect16-Jan-07 10:18
alect16-Jan-07 10:18 
Questionusing CSS programatically Pin
Tina P13-Jan-07 17:12
Tina P13-Jan-07 17:12 
AnswerRe: using CSS programatically Pin
jamesInvader13-Jan-07 19:27
jamesInvader13-Jan-07 19:27 
AnswerRe: using CSS programatically Pin
George L. Jackson14-Jan-07 4:12
George L. Jackson14-Jan-07 4:12 
Questionnewlines in xmldocument [modified] Pin
livez11-Jan-07 22:00
livez11-Jan-07 22:00 
AnswerRe: newlines in xmldocument Pin
led mike12-Jan-07 5:19
led mike12-Jan-07 5:19 
GeneralRe: newlines in xmldocument Pin
livez14-Jan-07 21:59
livez14-Jan-07 21:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.