[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to process elements with in elements...

Subject: How to process elements with in elements...
From: "Mohammed Rahman" <mrahman@xxxxxxxxxxxx>
Date: Fri, 1 Jun 2001 11:56:07 -0700
b art2
Hi all,
I have an xml look like this:

<?xml version="1.0" ?>
<articles>
	<article>
	<title> Title One </title>
		<section sid="1">
			<text tid="1.1"> aaa1 </text>
			<allAtr>
				<atr1> a-atr1 </atr1>
				<atr2> a-atr2 </atr2>
			</allAtr>

			<text tid ="1.2"> aaa2 </text>
			<allAtr>
				<atr1> x-art1 </atr1>
				<atr2> x-atr2 </atr2>
			</allAtr>
			<section sid="1.1">
				<text tid="1.1.1"> bbb  </text>
				<allAtr>
					<atr1> b-art1 </atr1>
					<atr2> b-art2 </atr2>
				</allAtr>
				<text tid="1.1.2"> ccc  </text>
				<allAtr>
					<atr1> c-atr1 </atr1>
					<atr2> c-atr2 </atr2>
				</allAtr>
			</section>
		<section sid="2">
			<text tid="2.1"> ddd </text>
			<allAtr>
				<atr1> d-atr1 </atr1>
				<atr2> d-atr2 </atr2>
			</allAtr>
			.....
			....
		</section>
		</section>
	</article>
</articles>

The processing xsl look like this:
<?xml version="1.0" encoding='ISO-8859-1' ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

                version="1.0">

<xsl:output cdata-section-elements="text"/>

<xsl:template match="articles" >

<xsl:apply-templates  />

</xsl:template>

<xsl:template match="article" >
<articles>

<xsl:attribute name="feedSource">
                        <xsl:value-of select="'ModuleOne'" />
                </xsl:attribute>
                <xsl:attribute name="folderName">
                        <xsl:value-of select="'MyFolder'" />
                </xsl:attribute>

                <xsl:attribute name="textInCData">
                        <xsl:value-of select="'true'" />
                </xsl:attribute>
              <xsl:apply-templates select="section"/>

</articles>
</xsl:template>



<xsl:template match="section" >
<article>



                <title>
                        <xsl:value-of select="./allAtr/atr1" />
                </title> <xsl:text>
</xsl:text>
                <displayableName>
                        <xsl:value-of select="./allAtr/atr2" />
                </displayableName> <xsl:text>
</xsl:text>



                 <text>

                        <xsl:text
disable-output-escaping="yes">&lt;p></xsl:text>
                        <xsl:apply-templates select="text/." />
                        <xsl:text
disable-output-escaping="yes">&lt;/p></xsl:text>
                        <xsl:text
disable-output-escaping="yes">&lt;p></xsl:text>

                </text>
<xsl:text>
</xsl:text>
                <xsl:text>
</xsl:text>
<xsl:apply-templates select="section"/>

</article>
  </xsl:template>

</xsl:stylesheet>


The result I get is:

<?xml version="1.0" encoding="utf-8"?>
<articles feedSource="ModuleOne" folderName="MyFolder" textInCData="true">
   <article>
      <title>a-atr1</title>

      <displayableName>a-atr2</displayableName>

      <text>
         <![CDATA[<p> aaa1  aaa2 </p><p>]]>
      </text>

      <article>
         <title>b-art1</title>

         <displayableName>b-art2</displayableName>

         <text>
            <![CDATA[<p> bbb   ccc  </p><p>]]>
         </text>
      </article>

      <article>
         <title>d-atr1</title>

         <displayableName>d-atr2</displayableName>

         <text>
            <![CDATA[<p> ddd </p><p>]]>
         </text>
      </article>
   </article>
</articles>

..... But I want my result to be:

<?xml version="1.0" encoding="utf-8"?>
<articles feedSource="ModuleOne" folderName="MyFolder" textInCData="true">
   <article>
      <title>a-atr1</title>

      <displayableName>a-atr2</displayableName>

      <text>
         <![CDATA[<p> aaa1  </p><p>]]>
      </text>
   </article>
   <article>
      <title>x-atr1</title>

      <displayableName>x-atr2</displayableName>

      <text>
         <![CDATA[<p> aaa2  </p><p>]]>
      </text>
   </article>


----- rest of the article tags -----
</articles>


Please help!!



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.