cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Anthony Davies <adav...@micromuse.com>
Subject org.apache.cocoon.transformation.SourceWritingTransformer
Date Thu, 12 Feb 2004 15:35:16 GMT
Hi,

I'm trying to get this transformer working so that I can write xml on 
the fly on my server. Unfortunately, I can't get this component to work. 
The relevant sitemap bits as I have them are:

   <map:transformer logger="sitemap.transformer.tofile" name="tofile" 
src="org.apache.cocoon.transformation.SourceWritingTransformer">
     <map:parameter name="serializer" value="xml"/>
   </map:transformer>

              <map:generate src="doclist.xml"/>
              <map:transform src="adminXSL/altersubmit.xsl"/>
              <map:transform type="tofile">
                <map:parameter name="serializer" value="xml"/>
              </map:transform>

altersubmit.xsl is:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:fo="http://www.w3.org/1999/XSL/Format" 
xmlns:source="http://www.apache.org/cocoon/transformer/source">
  <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" 
doctype-system="doclist.dtd"/>
  <xsl:param name="id"/>
  <xsl:param name="product"/>
  <xsl:param name="suppgroup"/>
  <xsl:param name="version"/>
  <xsl:param name="comment"/>

  <xsl:template match="/">
    <source:write create="true">
      <source:source>file://poo.xml</source:source>
      <source:fragment>
        <xsl:apply-templates/>
      </source:fragment>
    </source:write>
  </xsl:template>

  <xsl:template match="*">
    <xsl:choose>
      <xsl:when test="@id = $id">
        <xsl:choose>
          <xsl:when test="starts-with($id, 'p')">
            <xsl:element name="Product">
              <xsl:attribute name="ProductName"><xsl:value-of 
select="$product"/></xsl:attribute>
              <xsl:attribute name="id"><xsl:value-of 
select="$id"/></xsl:attribute>
              <xsl:element name="Comment"><xsl:value-of 
select="$comment"/></xsl:element>
              <xsl:apply-templates/>
            </xsl:element>
          </xsl:when>
          <xsl:when test="starts-with($id, 's')">
            <xsl:element name="SupplementalGroup">
              <xsl:attribute name="GroupName"><xsl:value-of 
select="$suppgroup"/></xsl:attribute>
              <xsl:attribute name="id"><xsl:value-of 
select="$id"/></xsl:attribute>
              <xsl:apply-templates/>
            </xsl:element>
          </xsl:when>
          <xsl:when test="starts-with($id, 'v')">
            <xsl:element name="Version">
              <xsl:attribute name="Number"><xsl:value-of 
select="$version"/></xsl:attribute>
              <xsl:attribute name="id"><xsl:value-of 
select="$id"/></xsl:attribute>
              <xsl:apply-templates/>
            </xsl:element>
          </xsl:when>
        </xsl:choose>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates select="@*"/>
          <xsl:apply-templates/>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="text()">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="@*">
    <xsl:copy>
      <xsl:apply-templates select="@*"/>
      <xsl:apply-templates/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>

Any help would be very much appreciated.

Thanks,

Anthony Davies.
Documentation Engineer
MSN: dravoski@hotmail.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message