Reputation: 27
As i said earlier I have started learning XSLT
When I am working on that I getting an wrong type of XML Format
Input
<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig note-ref="no">
<access-panel>113AL</access-panel>
<access-panel>119AL</access-panel>
</testingcongif>
Output
<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig>
<panel><panelid>113AL</panelid></panel>
<panel><panelid>119AL</panelid></panel>
</testingconfig>
My XSL
<?xml version="1.0" encoding="ISO-8859-1"?>
<testingconfig>
<xsl:for-each select="testingconfig">
<panel>
<panelid>
<xsl:value-of select="*"/>
</panelid>
</panel>
</xsl:for-each>
</testingconfig>
Out put for this is
<testingconfig>
<panel>
<panelid>
113AL 119AL
</panelid>
</panel>
</testingconfig>
Can any one help me here where i am doing mistake and pls help me how to do it in XSLT 2.0
Pls help me
Thanks & Regards M
Upvotes: 0
Views: 12206
Reputation: 1
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<testingconfig>
<xsl:for-each select="testingconfig/access-panel">
<panel><panelid><xsl:value-of select="." /></panelid></panel>
</xsl:for-each>
</testingconfig>
</xsl:template>
</xsl:stylesheet>
Upvotes: 0
Reputation: 163585
You just break it down into a set of transformation rules. For example:
<xsl:template match="testingfig">
<tscon><xsl:value-of select="."/></tscon>
</xsl:template>
<xsl:template match="config">
<testingvalue>
<testingtype>mar</testingtype>
<testid>mar<xsl:value-of select="."/></testid>
</testingvalue>
</xsl:template>
However, I'm a bit concerned that by giving you these examples I'm leading you by the hand into a swamp where you will get quickly stuck. It seems to me from your question that you are right at the beginning of learning this language, and asking on a forum for a solution to one simple problem is not really the best learning strategy. You can't learn a programming language by trial and error, or by copying noddy examples. You need to go away and read some books or tutorials.
Upvotes: 7