Click here to Skip to main content
15,900,818 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionHelp need for XSL file Pin
_anil_17-Sep-07 23:03
_anil_17-Sep-07 23:03 
I want to create a XSL file, that can merge two XML file.

The first XML file is of

<Root>
<ECV>
<ECID>0100</ECID>
<Type>LIST</Type>
<Size>32</Size>
<Name>SNSPOL</Name>
<Desc>Set sensor attribute setting</Desc>
<Variable ID="1">
<SubVal>
<Type>INT</Type>
<Size>1</Size>
<Name>SNSPOL1</Name>
<Val>0</Val>
</SubVal>
<SubVal>
<Type>INT</Type>
<Size>1</Size>
<Name>SNSPOL2</Name>
<Val>0</Val>
</SubVal>
<SubVal>
<Type>INT</Type>
<Size>1</Size>
<Name>SNSPOL3</Name>
<Val>0</Val>
</SubVal>
</SubVal>
</Variable>
</ECV>
</Root>

The Second one is of the format
<Root>
<ECV>
<EcsID>109</EcsID>
<OrgID>0100</OrgID>
<Type>3</Type>
<Size>32</Size>
<Name>SNSPOL</Name>
<Description>Set sensor attribute setting</Description>
<Variable ID="1">
<SubVar>
<EcsID>109</EcsID>
<Type>7</Type>
<Size>1</Size>
<Name>SNSPOL</Name>
</SubVar>
</Variable>
</ECV>
<Root>


I want to add the <EcsId> from the second XML file to the first XML file.

I tried in this way.
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" />
<!-- load the merge file -->
<xsl:variable name="ecvs" select="document('ECV_M121.xml')" />
<xsl:template match="/">
<Root>
<xsl:for-each select="Root/ECV">
<!-- cache the employee's ID -->
<xsl:variable name="name">
<xsl:value-of select="./Name" />
</xsl:variable>
<!-- copy the child nodes -->
<ECV>
<xsl:copy-of select="$ecvs/Root/ECV[Name=$name]/EcsID" />
<!-- copy the children of the matching employee node from the merge file -->
<xsl:copy-of select="child::*" />
</ECV>
</xsl:for-each>
</Root>
</xsl:stylesheet>

I was able to add the EcsId in the first level. But for the second level not able to do.
Since I have never written any XSLT programming I need some of your hint.



Regards
Anil
QuestionProblem with SQL Server bulk load XML def Pin
mintxelas17-Sep-07 22:44
mintxelas17-Sep-07 22:44 
Questionlimited iteration Pin
TClarke14-Sep-07 2:11
TClarke14-Sep-07 2:11 
AnswerRe: limited iteration Pin
George L. Jackson14-Sep-07 11:43
George L. Jackson14-Sep-07 11:43 
GeneralRe: limited iteration Pin
TClarke17-Sep-07 0:28
TClarke17-Sep-07 0:28 
GeneralRe: limited iteration [modified] Pin
George L. Jackson17-Sep-07 9:57
George L. Jackson17-Sep-07 9:57 
GeneralRe: limited iteration Pin
TClarke3-Oct-07 4:11
TClarke3-Oct-07 4:11 
Questionxml to html with c# Help Please Pin
phillippio13-Sep-07 13:14
phillippio13-Sep-07 13:14 
AnswerRe: xml to html with c# Help Please Pin
George L. Jackson14-Sep-07 1:48
George L. Jackson14-Sep-07 1:48 
GeneralRe: xml to html with c# Help Please Pin
phillippio14-Sep-07 11:11
phillippio14-Sep-07 11:11 
GeneralRe: xml to html with c# Help Please Pin
George L. Jackson14-Sep-07 11:39
George L. Jackson14-Sep-07 11:39 
QuestionWriting xml as a DiffGram Pin
steve_rm12-Sep-07 21:50
steve_rm12-Sep-07 21:50 
QuestionWant to use xml as localdatabse Pin
manuo512-Sep-07 0:01
manuo512-Sep-07 0:01 
QuestionXML file format Pin
VK-Cadec11-Sep-07 2:21
VK-Cadec11-Sep-07 2:21 
AnswerRe: XML file format Pin
George L. Jackson11-Sep-07 14:17
George L. Jackson11-Sep-07 14:17 
GeneralChoice of Value Types in Field Pin
Brady Kelly11-Sep-07 1:38
Brady Kelly11-Sep-07 1:38 
Questionhow to use the distinct-nodes function? Pin
Rocky#11-Sep-07 0:30
Rocky#11-Sep-07 0:30 
Questiongeneralizing the tabular display of xml data Pin
Rocky#10-Sep-07 20:23
Rocky#10-Sep-07 20:23 
QuestionHow to XSL parse 300 mg XML file? Pin
mcsdgal7-Sep-07 8:21
mcsdgal7-Sep-07 8:21 
NewsReding xml node in windows Forms [modified] Pin
chakran6-Sep-07 1:10
chakran6-Sep-07 1:10 
GeneralRe: Reding xml node in windows Forms Pin
Chetan Patel7-Sep-07 2:39
Chetan Patel7-Sep-07 2:39 
AnswerRe: Reding xml node in windows Forms Pin
israr Ali .NET7-Sep-07 2:39
israr Ali .NET7-Sep-07 2:39 
QuestionCalling a template recursively?? Pin
Rocky#5-Sep-07 0:23
Rocky#5-Sep-07 0:23 
AnswerRe: Calling a template recursively?? Pin
George L. Jackson5-Sep-07 2:15
George L. Jackson5-Sep-07 2:15 
GeneralRe: Calling a template recursively?? Pin
Rocky#5-Sep-07 2:57
Rocky#5-Sep-07 2:57 

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.