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]
Other format: [Raw text]

Re: xsl-element not allowed directly below xsl-stylesheet?


Hi Christer,

> I have an XSL stylesheet that have the structure:
>
> <xsl:stylesheet>
>
>  <xsl:template match="form1">
>         ...
>  </xsl:template>  
>
>  <xsl:template match="form2">
>         ...
>  </xsl:template> 
>
>  <xsl:template match="form3">
>         ...
>  </xsl:template>
>
> </xsl:stylesheet>
>
> And now I need an element tag that starts before form2 and ends
> after form3. But when I try to include an <xsl:element> before the
> <xsl:template> tag I get an error saying that <xsl:stylesheet> can't
> contain <xsl:element> tags.
>
> Is there any other way of specifying an element? 

The templates that you have in your stylesheet actually say very
little about the structure of your output (or your input). Each
template simply says "when you see an X, do Y". What determines the
structure of the output is the order in which you apply templates to
the elements in your source.

So, you haven't told us the structure of your source document, but I'm
guessing that it looks something like:

<forms>
  <form1>...</form1>
  <form2>...</form2>
  <form3>...</form3>
</forms>

In that case, to get an element that wraps the results of processing
the form2 and form3 elements, you need to create that element in a
template that matches the forms element -- you use that template to
structure the output of the stylesheet:

<xsl:template match="forms">
  <xsl:apply-templates select="form1" />
  <element>
    <xsl:apply-templates select="form2 | form3" />
  </element>
</xsl:template>

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 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]