Subversion Repositories general

Compare Revisions

Ignore whitespace Rev 519 → Rev 520

/sun/xmleditor/trunk/src/plugins/regionEditorPlugin/RegionEditorPluginTransformBack.xsl
1,123 → 1,12
<!-- status: first try for regioneditor -->
<!-- status: testing for regioneditor -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
 
<!-- these parameters can be given from outside -->
<xsl:param name="input">/</xsl:param><!-- eg. /XMLEDITORCONFIGURATION/DEFAULTPLUGIN -->
<xsl:param name="elementnamenew">standardplugin</xsl:param>
 
<xsl:template match="/">
<xsl:variable name="levelremaining" select="substring-after($input, '/')" />
 
<xsl:message><xsl:value-of select="concat('outside-parameter input: ', $input)"/></xsl:message>
<xsl:message><xsl:value-of select="concat('outside-parameter elementnamenew: ', $elementnamenew)"/></xsl:message>
 
<xsl:for-each select="node()">
<xsl:call-template name="selecter">
<xsl:with-param name="levelremaining" select="$levelremaining" />
</xsl:call-template>
</xsl:for-each>
<xsl:apply-templates />
</xsl:template>
 
<xsl:template name="selecter">
<xsl:param name="levelremaining" />
<xsl:variable name="level" select="substring-before( concat($levelremaining, '/'), '/')" />
<xsl:variable name="nextlevels" select="substring-after($levelremaining, '/')" />
<!-- if this node belongs to the right path
then work on childs with the selecter -->
<xsl:if test = "(name() = $level)">
<xsl:message>selecter-case: belongs to right path</xsl:message>
<xsl:element name="name()">
<!-- if this is the last level this is the node which must be converted
then convert the node -->
<xsl:if test = "( ('' = $nextlevels)
and not('' = name()) )"><!-- avoid too many tags from matcher -->
<xsl:message>selecter-case: last level</xsl:message>
<xsl:apply-templates select="self::node()">
</xsl:apply-templates>
</xsl:if>
<!-- else (if there are levels left) work on childs -->
<xsl:if test = "not('' = $nextlevels)">
<xsl:message>selecter-case: levels left</xsl:message>
<xsl:copy>
<xsl:for-each select="attribute::*">
<xsl:attribute name="{name(.)}">
<xsl:value-of select="self::node()" />
</xsl:attribute>
</xsl:for-each>
<xsl:for-each select="node()">
<xsl:call-template name="selecter">
<xsl:with-param name="levelremaining" select="$nextlevels" />
</xsl:call-template>
</xsl:for-each>
</xsl:copy>
</xsl:if>
</xsl:element>
</xsl:if>
<!-- else simply copy the node with childs -->
<xsl:if test = "not(name() = $level)">
<xsl:message>selecter-case: must only be copied and never touched in future</xsl:message>
<xsl:copy-of select="self::node()" />
</xsl:if>
</xsl:template>
 
<xsl:template match="REGIONSET"><!-- element-plugin association -->
<xsl:element name="Regionensatz">
 
<!-- work on attributes -->
<xsl:attribute name="Bild">
<xsl:value-of select="@image" />
</xsl:attribute>
<xsl:for-each select="attribute::*">
<xsl:if test = "not(name(.) = ('image'))">
<xsl:attribute name="{name(.)}">
<xsl:value-of select="self::node()" />
</xsl:attribute>
</xsl:if>
</xsl:for-each>
 
<!-- work on childs -->
<xsl:for-each select="RECT">
<xsl:element name="Bereich">
<xsl:attribute name="x">
<xsl:value-of select="@x" />
</xsl:attribute>
<xsl:attribute name="y">
<xsl:value-of select="@y" />
</xsl:attribute>
<xsl:attribute name="Breite">
<xsl:value-of select="@b" />
</xsl:attribute>
<xsl:attribute name="Hoehe">
<xsl:value-of select="@h" />
</xsl:attribute>
<xsl:for-each select="attribute::*">
<xsl:if test = "not(name(.) = 'x')">
<xsl:if test = "not(name(.) = 'y')">
<xsl:if test = "not(name(.) = 'b')">
<xsl:if test = "not(name(.) = 'h')">
<xsl:attribute name="{name(.)}">
<xsl:value-of select="self::node()" />
</xsl:attribute>
</xsl:if></xsl:if></xsl:if></xsl:if>
</xsl:for-each>
<xsl:for-each select="node()">
<xsl:copy-of select="self::node()" />
</xsl:for-each>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="node()">
<xsl:if test = "not(name(.) = 'RECT')">
<xsl:copy-of select="self::node()" />
</xsl:if>
</xsl:for-each>
 
</xsl:element>
</xsl:template>
 
<xsl:template match="REGIONSET"><!-- element-plugin association -->
<xsl:template match="node()">
<xsl:copy-of select="." />
</xsl:template>