OXF Users:

Well, this is a first pass and I am certain there are other ways
to do this more efficiently with generated nodes, but for now,
I offer a simple way to let clients edit the static part of 
various dynamic pages by transforming the xhtml into xsl.
The key is using <span> elements, at times where they are 
not legally valid but where most wysiwyg editors will 
not complain.

Given:

<table>
  <span class="for-each" href="/root/customer">
    <tr>
      <td><span class="value-of" href="first-name"/></td>
      <td><span class="value-of" href="last-name"/></td>
    </tr>
  </span>
</table>

[I used href, which is deprecated for xhtml, but seems so 
appropriate.  Unless you are validating the xhtml during
processing, I think there will be no problem]

Transformed against:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
 xmlns:xforms="http://www.w3.org/2002/01/xforms";
 xmlns:d="http://orbeon.org/oxf/xml/document";>
    
 <xsl:template match="/">
   <xsl:element name="xsl:stylesheet">
     <xsl:attribute name="version">
       <xsl:value-of select="'1.0'"/>
     </xsl:attribute>
     <xsl:element name="xsl:template">
       <xsl:attribute name="match">
         <xsl:value-of select="'/'"/>
       </xsl:attribute>
       <xsl:apply-templates/>
     </xsl:element>
   </xsl:element>
 </xsl:template>

  <xsl:template match="node() | @*">
    <xsl:choose>
      <xsl:when test="local-name()='span'">
        <xsl:element name="xsl:[EMAIL PROTECTED]">
          <xsl:attribute name="select">
            <xsl:value-of select="@href"/>
          </xsl:attribute>
          <xsl:apply-templates select="node()"/>
        </xsl:element>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates select="node() | @*"/>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

</xsl:stylesheet>


The following pipeline will transform to xsl then again but
with the data
<p:config xmlns:p="http://www.orbeon.com/oxf/pipeline";>

    <!-- Transform the xhtml into a stylesheet -->

 <p:processor uri="oxf/processor/xslt">
  <p:input name="config" href="./index.xsl"/>
  <p:input name="data" href="./index.html"/>
  <p:output name="data" id="xsl"/>
 </p:processor>
 
 <!-- Process xml data with stylesheet -->

 <p:processor uri="oxf/processor/xslt">
  <p:input name="config" href="#xsl"/>
  <p:input name="data">
   <root>
    <customer>
      <first-name>Joe</first-name>
      <last-name>CEO</last-name>
    </customer>
    <customer>
     <first-name>Jane</first-name>
     <last-name>VP</last-name>
    </customer>
   </root>
  </p:input>
  <p:output name="data" id="xsl2"/>
 </p:processor>

 <!-- Deliver html -->

 <p:processor uri="oxf/processor/html-serializer">
  <p:input name="config">
   <config/>
  </p:input>
  <p:input name="data" href="#xsl2"/>
 </p:processor>

</p:config>

The result will be

<table>
  <tr>
    <td>Joe</td>
    <td>CEO</td>
  </tr>
  <tr>
    <td>Jane</td>
    <td>VP</td>
  </tr>
</table>

Thanks for the help along the way.

============================================
Replying to a list?  I'll get my copy there!

Hank Ratzesberger
http://crustal.ucsb.edu/ | http://neesgrid.org/
Institute for Crustal Studies
University of California, Santa Barbara
============================================
_______________________________________________
oxf-users mailing list
[EMAIL PROTECTED]
http://mail.orbeon.com/mailman/listinfo/oxf-users

Reply via email to