Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


using xslt axes

From: Manish <cse.manish@-----.--->
To: NULL
Date: 5/28/2009 5:18:00 AM
Hi,

I have an xml file and I am trying to get some text output from the
xml data using xslt transformation. (using .Net classes.).

I am using the preceding/following axes of the xslt to get the desired
output. Requirement is to ignore the xml nodes which have one
attribute's value repeated in the subsequent nodes ("main/root/test/
new/@key" attribute value in below example.).

The problem is that the preceding and following axes of xslt searches
in all the nodes instead of searching only in the child nodes of the
current node.

The current and expected output is as shown below:

<b>xml:</b>
<main>
    <root>
        <test name="1">
            <new key="4" />
            <new key="1" />
            <new key="3" />
            <new key="1" />
        </test>
        <test name="2">
            <new key="50"/>
            <new key="10"/>
            <new key="1" />
            <new key="60"/>
            <new key="70"/>
            <new key="70"/>
        </test>
        <test name="3">
            <new key="8" />
            <new key="1" />
            <new key="3" />
            <new key="9" />
            <new key="7" />
            <new key="7" />
        </test>
    </root>
</main>

<b>xslt:</b>

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-
prefixes="msxsl">
    <xsl:output  method="text" />
    <xsl:template match="main" xml:space="preserve">

        <xsl:for-each select="root/test">
        <xsl:for-each select=" *[not(preceding::*/@key =
@key) ]">
        //<xsl:value-of select="@key"/>
        </xsl:for-each>
        </xsl:for-each>

   </xsl:template>
</xsl:stylesheet>

<b>Current output:</b>
//4
//1
//3

//50
//10
//60
//70

//8
//9
//7

<b>Expected output:</b>
//4
//1
//3

//50
//10
//1
//60
//70

//8
//1
//3
//9
//7


The C# code which i am using for transformation is:

XslCompiledTransform transformer = new XslCompiledTransform();
transformer.Load(@"C:\test.xslt");
transformer.Transform(@"C:\XMLFile1.xml", @"C:
\Class1.cs"(OUTPUT_FILE));


Can anyone tell if this is the expected behaviour of 'preceding' axes.
And how to get the expected output. (using xslt 1.0)


Thanks in advance.
Manish Gupta


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent