Update of /var/cvs/applications/richtext/config/xslt
In directory james.mmbase.org:/tmp/cvs-serv25148/config/xslt
Modified Files:
2rich.xslt 2xhtml.xslt mmxf2rich.xslt mmxf2xhtml.xslt
Log Message:
Made also 'wiki' syntax understand br's
See also: http://cvs.mmbase.org/viewcvs/applications/richtext/config/xslt
Index: 2rich.xslt
===================================================================
RCS file: /var/cvs/applications/richtext/config/xslt/2rich.xslt,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- 2rich.xslt 15 Apr 2008 15:54:52 -0000 1.3
+++ 2rich.xslt 22 Apr 2008 11:16:59 -0000 1.4
@@ -1,9 +1,12 @@
<!--
- This translates mmbase XML, normally containing an objects tag. The XML
related to this XSL is generated by
+ This translates mmbase XML, normally containing an objects tag (o:objects,
containing also fields with mmxf:mmxf). Results plain text. ('wiki' text).
+
+ The XML related to this XSL is generated by
org.mmbase.bridge.util.Generator, and the XSL is invoked by FormatterTag.
+
@author: Michiel Meeuwissen
- @version: $Id: 2rich.xslt,v 1.3 2008/04/15 15:54:52 michiel Exp $
+ @version: $Id: 2rich.xslt,v 1.4 2008/04/22 11:16:59 michiel Exp $
@since: MMBase-1.6
-->
<xsl:stylesheet
@@ -95,6 +98,9 @@
</xsl:choose>
</xsl:template>
-
+ <xsl:template match="mmxf:br">
+ <xsl:text>
+</xsl:text>
+ </xsl:template>
</xsl:stylesheet>
Index: 2xhtml.xslt
===================================================================
RCS file: /var/cvs/applications/richtext/config/xslt/2xhtml.xslt,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -b -r1.26 -r1.27
--- 2xhtml.xslt 1 Apr 2008 14:52:41 -0000 1.26
+++ 2xhtml.xslt 22 Apr 2008 11:16:59 -0000 1.27
@@ -3,7 +3,7 @@
org.mmbase.bridge.util.Generator, and the XSL is invoked by FormatterTag.
@author: Michiel Meeuwissen
- @version: $Id: 2xhtml.xslt,v 1.26 2008/04/01 14:52:41 michiel Exp $
+ @version: $Id: 2xhtml.xslt,v 1.27 2008/04/22 11:16:59 michiel Exp $
@since: MMBase-1.6
-->
<xsl:stylesheet
@@ -53,6 +53,9 @@
<!-- If objects is the entrance to this XML, then only handle the root
child of it -->
<xsl:template match="o:objects">
<div class="objects">
+ <!--
+ The first object is the 'core' object and is going to be shown. The
following nodes are only a 'repository' which will be used to resolve relations.
+ -->
<xsl:apply-templates select="o:object[1]" />
</div>
</xsl:template>
@@ -102,24 +105,43 @@
</xsl:template>
+ <!--
+
********************************************************************************
+ URL mode.
+ In URL mode, an actual URL is to be produced.
+ -->
+
<!--
- Produces an URL to point to a certain object.
+ Produces an URL to point to a certain MMBase Node.
+ This general version depends on external java code, to call the 'url'
function on the node.
-->
<xsl:template match="o:object" mode="url">
<xsl:value-of select="node:function($cloud, string(@id), 'url', $request)"
/>
</xsl:template>
+ <!--
+ For images, and atachments, the URL is determined a bit differently.
+ -->
<xsl:template match="o:[EMAIL PROTECTED] = 'images']|o:[EMAIL PROTECTED]
='attachments']|o:[EMAIL PROTECTED]'icaches']" mode="url">
<xsl:value-of select="node:saxonFunction($cloud, string(@id),
'servletpath')" />
</xsl:template>
-
+ <!--
+ For url objects the url is the url field.
+ -->
<xsl:template match="o:[EMAIL PROTECTED] = 'urls']" mode="url">
<xsl:value-of select="./o:[EMAIL PROTECTED]'url']" />
</xsl:template>
+ <!--
+
********************************************************************************
+ inline mode
+ Converts an MMBase node (presented by o:object) to inline HTML (so no
blocks).
+
+ -->
+
<!-- Produces output for one object
Required argument: relation, the relation object which made this
necessary.
position, last: if used in a list, these can be provided.
@@ -222,11 +244,10 @@
</xsl:template>
-
-
<!--
produces an icon for an object
Used for nodes of the type attachments, of course, but it can als be
imaginable for other objects
+
-->
<xsl:template match="o:object" mode="icon">
<img width="16" height="16" class="icon">
@@ -336,10 +357,14 @@
</xsl:template>
+ <!--
+ Given a relation object, produces a value for a style-class attribute in
HTML.
+ -->
<xsl:template match="o:[EMAIL PROTECTED] = 'blocks']" mode="class">
<xsl:param name="relation" />
<xsl:value-of select="$relation/o:[EMAIL PROTECTED]'class']" />
</xsl:template>
+
<!--
Produces output for one o:object of type 'blocks'
params: relation
@@ -379,7 +404,8 @@
<!--
- Produces output for one o:object of type urls
+ Produces output for one o:object of type urls, or 'segments' (used by
the richtext 'book' example).
+
params: relation, position, last
-->
<xsl:template match="o:[EMAIL PROTECTED] = 'urls']|o:[EMAIL PROTECTED] =
'segments']" mode="inline">
@@ -448,13 +474,19 @@
<xsl:template match="mmxf:[EMAIL PROTECTED] != '']|mmxf:[EMAIL PROTECTED] !=
'']|mmxf:a" >
<xsl:param name="in_a" />
+
+ <!--
+ The most difficult part of this XSL happens here.
+ Resolving of the idrels.
+ -->
+
<!-- store all 'relation' nodes of this node for convenience in $rels:-->
<xsl:variable name="rels" select="ancestor::o:object/o:[EMAIL
PROTECTED]'idrel']" />
<!-- also for conveniences: all related nodes to this node-->
+ <!--
<xsl:variable name="related_to_node" select="id($rels/@related)" />
-
-
+ -->
<xsl:variable name="relations" select="id($rels/@object)[o:[EMAIL
PROTECTED]'id'] = current()/@id]" />
<xsl:apply-templates select="." mode="with_relations">
Index: mmxf2rich.xslt
===================================================================
RCS file: /var/cvs/applications/richtext/config/xslt/mmxf2rich.xslt,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- mmxf2rich.xslt 1 Apr 2008 14:52:41 -0000 1.4
+++ mmxf2rich.xslt 22 Apr 2008 11:16:59 -0000 1.5
@@ -2,7 +2,7 @@
This translates a mmbase XML field to enriched ASCII
@author: Michiel Meeuwissen
- @version: $Id: mmxf2rich.xslt,v 1.4 2008/04/01 14:52:41 michiel Exp $
+ @version: $Id: mmxf2rich.xslt,v 1.5 2008/04/22 11:16:59 michiel Exp $
@since: MMBase-1.6
-->
<xsl:stylesheet
@@ -20,7 +20,7 @@
<xsl:template match = "mmxf:p|mmxf:ul|mmxf:ol|mmxf:table" >
<xsl:apply-templates select="." mode="rels" />
- <xsl:apply-templates select="mmxf:a|mmxf:em|text()|mmxf:ul|mmxf:ol" />
+ <xsl:apply-templates
select="mmxf:a|mmxf:em|text()|mmxf:ul|mmxf:ol|mmxf:br" />
<xsl:text>

</xsl:text>
</xsl:template>
Index: mmxf2xhtml.xslt
===================================================================
RCS file: /var/cvs/applications/richtext/config/xslt/mmxf2xhtml.xslt,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- mmxf2xhtml.xslt 27 Feb 2007 12:28:28 -0000 1.8
+++ mmxf2xhtml.xslt 22 Apr 2008 11:16:59 -0000 1.9
@@ -1,10 +1,11 @@
<!--
- This translates a mmbase XML field to XHTML1. So if you have MMXF
+ This translates an mmbase XML field to XHTML1. So if you have MMXF
fields in your datbase, this describes how they are presented as XHTML.
- MMXF itself is besides the mmxf tag itself a subset of XHTML2.
+ MMXF itself is, besides the mmxf tag itself, nearly a subset of XHTML2, so
this XSLT is pretty straightforward.
- @version $Id: mmxf2xhtml.xslt,v 1.8 2007/02/27 12:28:28 michiel Exp $
+
+ @version $Id: mmxf2xhtml.xslt,v 1.9 2008/04/22 11:16:59 michiel Exp $
@author Michiel Meeuwissen
-->
<xsl:stylesheet
@@ -25,6 +26,7 @@
<xsl:apply-templates
select="mmxf:section|mmxf:p|mmxf:table|mmxf:ul|mmxf:ol|text()" mode="root" />
</xsl:when>
<xsl:otherwise>
+ <!-- do not produce emptyness -->
<p></p>
</xsl:otherwise>
</xsl:choose>
@@ -32,6 +34,7 @@
</xsl:template>
<xsl:template match = "text()" mode="root">
+ <!-- produce valid xml, so text() at root must be wrapped in a p -->
<p>
<xsl:copy-of select="." />
</p>
@@ -78,6 +81,9 @@
</xsl:if>
</xsl:template>
+ <!--
+ mmxf supports '@type' rather than '@style'. The mapping is controlled in
this template.
+ -->
<xsl:template match="mmxf:ul|mmxf:ol">
<xsl:element name="{name()}">
<xsl:if test="@type">
@@ -104,6 +110,9 @@
</xsl:template>
+ <!--
+ Text not in mode root, can simply be copied.
+ -->
<xsl:template match ="text()">
<xsl:copy-of select="." />
</xsl:template>
@@ -113,6 +122,12 @@
<xsl:apply-templates
select="mmxf:section|mmxf:h|mmxf:p|mmxf:ul|mmxf:ol|mmxf:table|mmxf:sub|mmxf:sup"
/>
</xsl:template>
+ <!--
+ Follow the templates to present the header at several nesting depths
(mmxf uses nesting of sections).
+
+ These templates are typical candidates to override.
+ -->
+
<xsl:template match="mmxf:h" mode="h1"><xsl:if
test="string(.)"><h3><xsl:apply-templates select="node()"
/></h3></xsl:if></xsl:template>
<xsl:template match="mmxf:h" mode="h2"><xsl:if
test="node()"><p><strong><xsl:apply-templates select="node()"
/></strong></p></xsl:if></xsl:template>
<xsl:template match="mmxf:h" mode="h3"><p><xsl:value-of select="node()"
/></p></xsl:template>
@@ -127,6 +142,12 @@
<xsl:apply-templates select="node()" /><br />
</xsl:template>
+
+ <!--
+ Dispatching of section depth to mmxf:h modes is done here.
+ You could override this, or choose to override the headers at different
depths using the modes h1-h8 themselves.
+ -->
+
<xsl:template match = "mmxf:h" >
<xsl:variable name="depth"><xsl:value-of
select="count(ancestor::mmxf:section)" /></xsl:variable>
<xsl:if test="$depth=1"><xsl:apply-templates select="." mode="h1"
/></xsl:if>
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs