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

RE: How to process elements with in elements...

Subject: RE: How to process elements with in elements...
From: "Tim Watts" <timw@xxxxxxx>
Date: Mon, 4 Jun 2001 10:37:34 +1000
process elements
Mohammed Raham,

You question is very long winded and requires people to wade through lots of
code.

I have removed a lot of white space from your code to make it easier to
read.

You seem to be getting
<articles feedSource="ModuleOne" folderName="MyFolder" textInCData="true">
<article>
      ...
      <article>
          ...
      </article>
</article>
...
<articles>
when you really want
<articles feedSource="ModuleOne" folderName="MyFolder" textInCData="true">
   <article>
      ...
   </article>
   ...
</articles>

Is that your question?

Or is it
<![CDATA[<p> bbb   ccc  </p><p>]]>
rather than
<![CDATA[<p> aaa1  </p><p>]]>
?

Could you ask a more specific question?
Pls. send the pertinant part of your code, rather than too much detail. It
will confuse those trying to help. :)

Tim

-----Original Message-----
From: Mohammed Rahman
Sent: Saturday, 2 June 2001 4:56 AM
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject:  How to process elements with in elements...


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>
</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>
</articles>


Please help!!



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


 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.