Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 19th, 2005, 03:49 PM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help generating text from xml

Hi!

I want to generate a text file with the following output using xslt:

Output: a + A + b + B + x;

I have the following xml:

<?xml version="1.0" encoding="UTF-8"?>
<exp kind="+">
     <exp kind="+">
          <exp kind="+">
               <exp kind="+">
                    <ident id="a"/>
                    <ident id="A"/>
               </exp>
               <ident id="b"/>
               <ident id="B"/>
               <ident id="x"/>
          </exp>
     </exp>
</exp>

How can I do this?

Bill Clay
 
Old April 21st, 2005, 04:18 AM
Authorized User
 
Join Date: Apr 2005
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">

                <xsl:apply-templates/>

    </xsl:template>

    <xsl:template match="exp">


                    <xsl:for-each select="descendant::ident">


                                    <xsl:if test="position() = 1">
                                        <xsl:text>Output: </xsl:text>
                                    </xsl:if>


                                    <xsl:value-of select="@id"/>

                                    <xsl:if test="position() &lt; last()">
                                        <xsl:text>+</xsl:text>
                                    </xsl:if>

                                    <xsl:if test="position() = last()">
                                        <xsl:text>;</xsl:text>
                                    </xsl:if>


                    </xsl:for-each>


    </xsl:template>

</xsl:stylesheet>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update text in the report after generating Rana AbuMari BOOK: Professional SQL Server 2005 Reporting Services ISBN: 0-7645-8497-9 0 February 24th, 2008 04:20 AM
Generating XML m_rajib Crystal Reports 0 May 4th, 2006 07:51 AM
generating XML through PHP Ashleek007 Beginning PHP 1 January 27th, 2006 08:16 AM
Generating documentation from the XML brko C# 2005 0 January 23rd, 2006 06:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.