0

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

5
  • I am not sure that it is right just to post a solution, so it is better to read w3schools.com/xsl/default.asp Commented May 18, 2012 at 5:14
  • Hi thanks for the reply This is actually sample i will convert the original Commented May 18, 2012 at 5:20
  • 1
    Both your source XML document and the wanted results aren't well-formed (I edited and corrected the former). Also, you haven't accepted the good answer you got -- please learn to do this (hint: by clicking on the check-mark next to the answer). Commented May 18, 2012 at 12:02
  • Hi thk u very much for the reply Commented May 20, 2012 at 7:51
  • Hi Dimitre I am new to this site I was not aware what to do ? Sorry for not clicking the check-mark Thanks for the reply I have started reading XSLT day ago Regards M Commented May 20, 2012 at 7:54

2 Answers 2

7

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.

Sign up to request clarification or add additional context in comments.

1 Comment

If I want to transform one XML structure to another, what references would you suggest to lean how to do that?
0
<?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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.