You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ben Anderson <be...@gmail.com> on 2004/12/24 14:37:56 UTC

[FORMS] overriding default stylesheets

Hi,
Does anyone have an elegant solution for overriding the default
stylesheets.  Basically I don't want to modify the sample stylesheets,
because I still want to these to be used as is for most of my forms. 
I want to be able to specify somehow that the xsl can be overridden,
but isn't by default.  This is the solution I came up with, but it's
not working.  Perhaps someone can help me figure out why or maybe
point me in a different direction...

sitemap.xmap
--------------------
      <!-- in this example, we'll say {1} is test -->
      <map:match pattern="forms/task/*-display">
       ....
        <map:select type="resource-exists">
          <map:when test="resources/forms-samples-styling-{1}.xsl">
            <map:transform
src="resources/forms-samples-styling-{1}.xsl" label="debug3"/>
          </map:when>
          <map:otherwise>
            <map:transform src="resources/forms-samples-styling.xsl"/>
          </map:otherwise>
        </map:select>

This part seems to be working ok...

forms-samples-stying-test.xsl
------------------------------------------
I changed the following line:
  <xsl:include href="forms-page-styling.xsl"/>
to:
  <!-- If I do get this working, a parameter would probably work
        better than the hard-coded "test", then this whole thing
        can probably be generic -->
  <xsl:include href="forms-page-styling-test.xsl"/>

forms-page-styling-test.xsl
-----------------------------------------
  <xsl:import href="forms-page-styling.xsl"/>

  <xsl:template match="fi:group[fi:styling/@layout='columns']"
mode="group-layout">
    <table border="0" summary="{fi:hint}">
      <tbody>
        <steel-city-football>
          <xsl:apply-templates select="fi:items/*"
mode="group-columns-content"/>
        </steel-city-football>
      </tbody>
    </table>
  </xsl:template>

It's this last step that isn't working.  I'm relatively new to xsl,
but I thought the import makes the stylesheet function the same as the
imported stylesheet except for what you override, but this is the part
that's broken because nothing is being transformed at all.

Any ideas?

Thanks and Merry Christmas Eve,
Ben

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


Re: [FORMS] overriding default stylesheets

Posted by Ben Anderson <be...@gmail.com>.
yeah - actually if I just change my example from <xsl:import> to
<xsl:include> - it works fine... wonder why the import doesn't work.

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


Re: [FORMS] overriding default stylesheets

Posted by Markus Heussen <he...@asspaxx.de>.
I do it like this:


sitemap.xmap:

<map:match type="wildcard" pattern="*.form">
   <map:generate type="file" src="forms/templates/{1}.template.xhtml.xml"/>
   <map:transform type="forms"/>
   <map:transform type="i18n"/>
   <map:transform type="xslt" src="forms/stylesheets/form.xhtml.xsl"/>
   <map:serialize type="xml"/>
</map:match>



form.xhtml.xsl:

<!--+
     | This parts includes the default form stylesheets
     | that are copied from the cocoon forms block to
     | the stylesheets folder under controlcenter/forms.
     | This stylesheets processes the standard stylesheets
     | and customizes with the templates you can see below.
     +-->
<xsl:include 
href="../../../resources/stylesheets/forms.fieldstyling.xhtml.xsl"/>
<xsl:include 
href="../../../resources/stylesheets/forms.pagestyling.xhtml.xsl"/>
...
...
...
<!--+
     | Override common stuff like fi:validation-message,
     | @required.
     +-->
<xsl:template match="fi:*" mode="common">
   <xsl:if test="@required='true'">
     <span class="forms-field-required">&#160;*&#160;</span>
   </xsl:if>
   <xsl:apply-templates select="fi:validation-message"/>
</xsl:template>


Hope this helps.

Merry X-mas!

Markus


Ben Anderson schrieb:
> Hi,
> Does anyone have an elegant solution for overriding the default
> stylesheets.  Basically I don't want to modify the sample stylesheets,
> because I still want to these to be used as is for most of my forms. 
> I want to be able to specify somehow that the xsl can be overridden,
> but isn't by default.  This is the solution I came up with, but it's
> not working.  Perhaps someone can help me figure out why or maybe
> point me in a different direction...
> 
> sitemap.xmap
> --------------------
>       <!-- in this example, we'll say {1} is test -->
>       <map:match pattern="forms/task/*-display">
>        ....
>         <map:select type="resource-exists">
>           <map:when test="resources/forms-samples-styling-{1}.xsl">
>             <map:transform
> src="resources/forms-samples-styling-{1}.xsl" label="debug3"/>
>           </map:when>
>           <map:otherwise>
>             <map:transform src="resources/forms-samples-styling.xsl"/>
>           </map:otherwise>
>         </map:select>
> 
> This part seems to be working ok...
> 
> forms-samples-stying-test.xsl
> ------------------------------------------
> I changed the following line:
>   <xsl:include href="forms-page-styling.xsl"/>
> to:
>   <!-- If I do get this working, a parameter would probably work
>         better than the hard-coded "test", then this whole thing
>         can probably be generic -->
>   <xsl:include href="forms-page-styling-test.xsl"/>
> 
> forms-page-styling-test.xsl
> -----------------------------------------
>   <xsl:import href="forms-page-styling.xsl"/>
> 
>   <xsl:template match="fi:group[fi:styling/@layout='columns']"
> mode="group-layout">
>     <table border="0" summary="{fi:hint}">
>       <tbody>
>         <steel-city-football>
>           <xsl:apply-templates select="fi:items/*"
> mode="group-columns-content"/>
>         </steel-city-football>
>       </tbody>
>     </table>
>   </xsl:template>
> 
> It's this last step that isn't working.  I'm relatively new to xsl,
> but I thought the import makes the stylesheet function the same as the
> imported stylesheet except for what you override, but this is the part
> that's broken because nothing is being transformed at all.
> 
> Any ideas?
> 
> Thanks and Merry Christmas Eve,
> Ben
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 
> 


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