Click here to Skip to main content
15,885,914 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: xml stylesheet does not work for IMG tag Pin
George L. Jackson24-Sep-07 0:27
George L. Jackson24-Sep-07 0:27 
QuestionXML Encryption on StreamWriter Pin
Member 450778122-Sep-07 6:01
Member 450778122-Sep-07 6:01 
QuestionHow to load xml file to a datatable Pin
Diego F.20-Sep-07 6:15
Diego F.20-Sep-07 6:15 
AnswerRe: How to load xml file to a datatable Pin
Diego F.20-Sep-07 7:14
Diego F.20-Sep-07 7:14 
GeneralRe: How to load xml file to a datatable Pin
Diego F.20-Sep-07 7:26
Diego F.20-Sep-07 7:26 
Questionxml stylesheet to customize Excel - How to change column width Pin
umakemesik18-Sep-07 11:59
umakemesik18-Sep-07 11:59 
AnswerRe: xml stylesheet to customize Excel - How to change column width Pin
Ed.Poore18-Sep-07 12:44
Ed.Poore18-Sep-07 12:44 
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 

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.