You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Roberto Viana <rv...@agency.com> on 2001/01/17 17:56:08 UTC

Excluding elements in XSL, How?

This should be more a specific question for a XSL newsgroup but anyway...

How can I exclude XML elements using a XSL?

for example:
I have a xml file that I want to format pasing it to a XSL, I only want to
format the children elements from page1, page2 elements should not appear in
my formatted file. I tryed this with the XSL described below but I get some
errors:

****************************************************************************
********
Error found handling the request

org.apache.xalan.xslt.XSLProcessorException: Can't have more than one root
on a DOM!

****************************************************************************
********

So in one word what I want to do is: extract data from this XML file, show
this extracted data and the remaining data in the XML should not appear in
the result page.

Thank you for your feedbak!

Rob.


=====XML file======
<documents>
<page1>
 <title>Hello 1</title>
 <content>
  <paragraph>This is my first Cocoon page!</paragraph>
 </content>
</page1>
<page2>
 <title>Hello 2</title>
 <content>
  <paragraph>This is my second Cocoon page!</paragraph>
 </content>
</page2>
</documents>

====XSL file======

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

  <xsl:template match="page1">
   <xsl:processing-instruction
name="cocoon-format">type="text/html"</xsl:processing-instruction>
   <html>
    <head>
     <title>
      <xsl:value-of select="title"/>
     </title>
    </head>
    <body bgcolor="#ffffff">
     <xsl:apply-templates/>
    </body>
   </html>
  </xsl:template>

  <xsl:template match="title">
   <h1 align="center">
    <xsl:apply-templates/>
   </h1>
  </xsl:template>

  <xsl:template match="paragraph">
   <p align="center">
    <i>
     <xsl:apply-templates/>
    </i>
   </p>
  </xsl:template>

</xsl:stylesheet>



================================================

AGENCY.COM : Amsterdam
Eekholt 40, 112 XH Diemen
Postbus 23447
1100 DX  Amsterdam Z.O. The Netherlands
T +31 (0)20 7994000
F +31 (0)20 7994001
@ mailto:rviana@agency.com
http://www.agency.com
ICQ# 47478252


===============================================


Re: Excluding elements in XSL, How?

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 17 Jan 2001, Roberto Viana wrote:

> This should be more a specific question for a XSL newsgroup but anyway...

no "but anyway" - ask on an XSL mailing list!

- donald