Tony Click wrote:
> 
> I had a previous question about how to pipe the output of one transform to
> another to which no one responded.  After going step by step I've discovered
> why my transforms aren't working as expected.
> 
> My problem is to take an xml file, transform it to another xml format and
> then transform it to html for presentation.  The reasons are pretty basic -
> I'll be getting xml files from different sources and it may be burdonsome
> for them to normalize the data.  My first transform will munge the data to a
> common format so that all the various display transforms know how to expect
> the data.
> 
> I've tested my normalization transform through cocoon and it works as
> expected.  When I pass a file that has been normalized through my
> presentation transform, it also works as expected.  When I attempt to pipe
> the output of the first transform directly to the second transform, it
> behaves as if the first transform never took place.
> 
> By going step by step through multiple transforms I have found out that a
> new element created by the first transform (as part of the normalization) is
> not comming through to the next transform as an element but as text.  The
> part that through me is it comes through as <channelSet> which looks like an
> element, but the second transform does not recognize it.
> 
> So my question is, if I create new elements in a transform, is it the
> correct behavior for them to appear not as element nodes, but as text for
> the subsequent transforms?

In any transform that is meant to be piped, you must explicitly create a copy
template like this:

<xsl:template match="node()|@*" priority="-1">
  <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
</xsl:template>

This is learned by experience--not by books.

When I add this template in my stylesheets, everything works as expected.
I have had 5 layers of stylesheets in my system, and there was very little
performance degradation.

In fact, you may find that performing a series of small changes will perform
quicker than one complex stylesheet.

S/MIME Cryptographic Signature

Reply via email to