tags:

views:

40

answers:

1

source:

<article>
<title>title1</title>
<description>des1</description>
<child>
  <children>
    <subarticle>
      <title>subtitle11</title>
      <description>subdes11</description>
    </subarticle>
  </children>
  <children>
    <subarticle>
      <title>subtitle12</title>
      <description>subdes12</description>
    </subarticle>
  </children>
</child>
</article>
<article>
<title>title2</title>
<description>des2</description>
<child>
  <children>
    <subarticle>
      <title>subtitle21</title>
      <description>subdes21</description>
    </subarticle>
  </children>
  <children>
    <subarticle>
      <title>subtitle22</title>
      <description>subdes22</description>
    </subarticle>
  </children>
</child>
</article>

after using xlst,i want the document to like this:

<article>
<title>title1</title>
<description>des1 des11 des12</description>
</article>

<article>
<title>title2</title>
<description>des2 des21 des22</description>
</article>

Is there somebody give any suggestion?Thank you !

+2  A: 

I guess "des11" and "des12" are supposed to be "subdes11" and "subdes12".

Try this:

<xsl:template match="article">
  <article>
    <title><xsl:value-of select="title/text()"/></title>
    <description>
      <xsl:value-of select="description/text()"/>
      <xsl:for-each select="child/children"/>
        <xsl:text> </xsl:text>
        <xsl:value-of select="subarticle/description/text()"/>
      </xsl:for-each>
    </description>
  </article>
</xsl:template>
AJPerez