This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: How to process elements with in 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@lists.mulberrytech.com
Subject: [xsl] 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]