You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by re...@apache.org on 2018/12/11 11:20:45 UTC
svn commit: r1848667 - in /jackrabbit/sandbox/docview-xslt: README.txt
docview2cnd.xslt
Author: reschke
Date: Tue Dec 11 11:20:45 2018
New Revision: 1848667
URL: http://svn.apache.org/viewvc?rev=1848667&view=rev
Log:
JCR-4397: XSLT for docview to CND conversion
Added:
jackrabbit/sandbox/docview-xslt/docview2cnd.xslt (with props)
Modified:
jackrabbit/sandbox/docview-xslt/README.txt
Modified: jackrabbit/sandbox/docview-xslt/README.txt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/docview-xslt/README.txt?rev=1848667&r1=1848666&r2=1848667&view=diff
==============================================================================
--- jackrabbit/sandbox/docview-xslt/README.txt (original)
+++ jackrabbit/sandbox/docview-xslt/README.txt Tue Dec 11 11:20:45 2018
@@ -1,2 +1,6 @@
XSLT pretty-printer for JCR document view export files
from https://issues.apache.org/jira/browse/JCR-1132
+
+XSLT conversion for JCR document view export files to CND format
+see https://issues.apache.org/jira/browse/JCR-4397
+
Added: jackrabbit/sandbox/docview-xslt/docview2cnd.xslt
URL: http://svn.apache.org/viewvc/jackrabbit/sandbox/docview-xslt/docview2cnd.xslt?rev=1848667&view=auto
==============================================================================
--- jackrabbit/sandbox/docview-xslt/docview2cnd.xslt (added)
+++ jackrabbit/sandbox/docview-xslt/docview2cnd.xslt Tue Dec 11 11:20:45 2018
@@ -0,0 +1,160 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<!-- run with XSLT 1.0 processor of your choice, for instance:
+
+ xsltproc docview2cnd.xslt xml-source
+
+-->
+
+<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0"
+>
+
+<xsl:output encoding="UTF-8" method="text" />
+
+<xsl:variable name="lcase" select="'abcdefghijklmnopqrstuvwxyz'" />
+<xsl:variable name="ucase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
+
+<xsl:template match="/">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="nodeTypes">
+ <xsl:variable name="prefixes">
+ <xsl:for-each select=".//text()[contains(.,':')]">
+ <xsl:value-of select="substring-before(.,':')"/>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:for-each select="namespace::*">
+ <xsl:if test="contains($prefixes,concat(name(),' '))">
+ <xsl:text><</xsl:text>
+ <xsl:value-of select="name()"/>
+ <xsl:text>='</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>'> </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text> </xsl:text>
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="nodeType">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:text>]</xsl:text>
+ <xsl:if test="supertypes">
+ <xsl:text> > </xsl:text>
+ <xsl:for-each select="supertypes/supertype">
+ <xsl:value-of select="."/>
+ <xsl:if test="position()!=last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:if>
+ <xsl:if test="@isMixin='true'">
+ <xsl:text> mixin </xsl:text>
+ </xsl:if>
+ <xsl:if test="@hasOrderableChildNodes='true'">
+ <xsl:text> orderable </xsl:text>
+ </xsl:if>
+ <xsl:if test="@primaryItemName and @primaryItemName!=''">
+ <xsl:text> primaryitem </xsl:text>
+ <xsl:value-of select="@primaryItemName"/>
+ <xsl:text> </xsl:text>
+ </xsl:if>
+ <xsl:for-each select="propertyDefinition">
+ <xsl:text> - </xsl:text>
+ <xsl:value-of select="@name"/>
+ <xsl:variable name="type" select="translate(@requiredType,$lcase,$ucase)"/>
+ <xsl:if test="$type!='STRING'">
+ <xsl:text> (</xsl:text>
+ <xsl:value-of select="$type"/>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ <xsl:if test="@autoCreated='true'">
+ <xsl:text> autocreated</xsl:text>
+ </xsl:if>
+ <xsl:if test="@mandatory='true'">
+ <xsl:text> mandatory</xsl:text>
+ </xsl:if>
+ <xsl:if test="@protected='true'">
+ <xsl:text> protected</xsl:text>
+ </xsl:if>
+ <xsl:if test="@onParentVersion!='COPY'">
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@onParentVersion"/>
+ </xsl:if>
+ <xsl:if test="@multiple='true'">
+ <xsl:text> multiple</xsl:text>
+ </xsl:if>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+ <xsl:for-each select="childNodeDefinition">
+ <xsl:text> + </xsl:text>
+ <xsl:call-template name="emit-string">
+ <xsl:with-param name="s" select="@name"/>
+ </xsl:call-template>
+ <xsl:if test="requiredPrimaryTypes/requiredPrimaryType">
+ <xsl:text> (</xsl:text>
+ <xsl:for-each select="requiredPrimaryTypes/requiredPrimaryType">
+ <xsl:value-of select="."/>
+ <xsl:if test="position()!=last()">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ <xsl:text>)</xsl:text>
+ </xsl:if>
+ <xsl:if test="@defaultPrimaryType!=''">
+ <xsl:text> = </xsl:text>
+ <xsl:value-of select="@defaultPrimaryType"/>
+ </xsl:if>
+ <xsl:if test="@autoCreated='true'">
+ <xsl:text> autocreated</xsl:text>
+ </xsl:if>
+ <xsl:if test="@mandatory='true'">
+ <xsl:text> mandatory</xsl:text>
+ </xsl:if>
+ <xsl:if test="@protected='true'">
+ <xsl:text> protected</xsl:text>
+ </xsl:if>
+ <xsl:if test="@onParentVersion!='COPY'">
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="@onParentVersion"/>
+ </xsl:if>
+ <xsl:if test="@sameNameSiblings='true'">
+ <xsl:text> sns</xsl:text>
+ </xsl:if>
+ <xsl:text> </xsl:text>
+ </xsl:for-each>
+ <xsl:text> </xsl:text>
+</xsl:template>
+
+<xsl:template name="emit-string">
+ <xsl:param name="s"/>
+ <xsl:choose>
+ <xsl:when test="contains($s,' ')">
+ <xsl:text>"</xsl:text>
+ <xsl:value-of select="$s"/>
+ <xsl:text>"</xsl:text>
+ </xsl:when>
+ <xsl:otherwise><xsl:value-of select="$s"/></xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:transform>
\ No newline at end of file
Propchange: jackrabbit/sandbox/docview-xslt/docview2cnd.xslt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: jackrabbit/sandbox/docview-xslt/docview2cnd.xslt
------------------------------------------------------------------------------
svn:executable = *