1,18 → 1,54 |
<!-- to-direction for RegionEditor |
status: not tested, should be not so long |
status: problems with namespace and comments |
updated to given schema from 15/07/2003 |
Last Revision: 18/07/2003 by Sascha Walkenhorst --> |
Last Revision: 25/07/2003 by Sascha Walkenhorst --> |
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
<xsl:output method="xml" indent="yes" /> |
|
|
<xsl:template match="/"> |
<xsl:apply-templates /> |
<xsl:template match="node()"> |
<xsl:if test="not(name() = ('REGIONS'))"> |
<xsl:if test="not(name() = ('REGIONSET'))"> |
<xsl:if test="not(name() = ('PHOTO'))"> |
<xsl:if test="not(name() = ('IMAGE'))"> |
<xsl:element name="{name()}"> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name()}"> |
<xsl:value-of select="." /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- |
<xsl:for-each select="namespace::*"> |
<xsl:attribute name="{name()}"> |
<xsl:value-of select="." /> |
</xsl:attribute> |
</xsl:for-each> |
--> |
|
<xsl:for-each select="node()"> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:template> |
|
<xsl:template match="text()"> |
<xsl:variable name="testWhetherEmpty"> |
<xsl:value-of select="." /> |
</xsl:variable> |
|
<xsl:if test="normalize-space($testWhetherEmpty) != ''"> |
<xsl:value-of select="$testWhetherEmpty" /> |
</xsl:if> |
</xsl:template> |
|
<xsl:template match="REGIONS"><!-- element-plugin association --> |
<xsl:element name="REGIONS"> |
<xsl:element name="REGIONSET"> |
<!-- set extra attribute saving the original name --> |
<xsl:attribute name="XMLEditorSavedNameOfNode"> |
<xsl:value-of select="'REGIONS'" /> |
</xsl:attribute> |
|
<!-- work on attributes --> |
<!-- get information of used image out of attribute 'image' --> |
21,7 → 57,7 |
</xsl:attribute> |
<!-- copy all other attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = ('image'))"> |
<xsl:if test="not(name(.) = 'image')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
32,6 → 68,13 |
<!-- get information of used rectangle out of child 'RECTANGLE' --> |
<xsl:for-each select="RECTANGLE"> |
<xsl:element name="RECTANGLE"> |
<!-- copy all attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- get coordinates --> |
<xsl:for-each select="COORDS"> |
<xsl:element name="COORDS"> |
48,10 → 91,10 |
<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(.) = 'w')"> |
<xsl:if test = "not(name(.) = 'h')"> |
<xsl:if test="not(name(.) = 'x')"> |
<xsl:if test="not(name(.) = 'y')"> |
<xsl:if test="not(name(.) = 'w')"> |
<xsl:if test="not(name(.) = 'h')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
58,8 → 101,12 |
</xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:for-each> |
<xsl:for-each select="COORD_DATA"> |
<xsl:element name="COORDS"> |
<!-- Insert an attribute which saves the original name of node, |
cause all nodes which contain data are transformed to a |
"COORDS" node. This extra information is used in back- |
67,10 → 114,7 |
<xsl:attribute name="XMLEditorSavedNameOfNode"> |
<xsl:value-of select="name(.)" /> |
</xsl:attribute> |
</xsl:element> |
</xsl:for-each> |
<xsl:for-each select="COORD_DATA"> |
<xsl:element name="COORDS"> |
|
<xsl:attribute name="x"> |
<xsl:value-of select="@x_pos" /> |
</xsl:attribute> |
84,10 → 128,10 |
<xsl:value-of select="@height" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = 'x_pos')"> |
<xsl:if test = "not(name(.) = 'y_pos')"> |
<xsl:if test = "not(name(.) = 'width')"> |
<xsl:if test = "not(name(.) = 'height')"> |
<xsl:if test="not(name(.) = 'x_pos')"> |
<xsl:if test="not(name(.) = 'y_pos')"> |
<xsl:if test="not(name(.) = 'width')"> |
<xsl:if test="not(name(.) = 'height')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
94,22 → 138,16 |
</xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
<!-- Insert an attribute which saves the original name of node, |
cause all nodes which contain data are transformed to a |
"COORDS" node. This extra information is used in back- |
transformation to restore the original name. --> |
<xsl:attribute name="XMLEditorSavedNameOfNode"> |
<xsl:value-of select="name(.)" /> |
</xsl:attribute> |
</xsl:element> |
</xsl:for-each> |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'COORDS')"> |
<xsl:if test = "not(name(.) = 'COORD_DATA')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'COORDS')"> |
<xsl:if test="not(name(.) = 'COORD_DATA')"> |
<xsl:apply-templates select="." /> |
</xsl:if></xsl:if> |
</xsl:for-each> |
</xsl:element> |
118,6 → 156,13 |
<!-- get information of used ellipse out of child 'ELLIPSE' --> |
<xsl:for-each select="ELLIPSE"> |
<xsl:element name="ELLIPSE"> |
<!-- copy all attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- get coordinates --> |
<xsl:for-each select="COORDS"> |
<xsl:element name="COORDS"> |
137,11 → 182,11 |
<xsl:value-of select="@angle" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = 'x')"> |
<xsl:if test = "not(name(.) = 'y')"> |
<xsl:if test = "not(name(.) = 'w')"> |
<xsl:if test = "not(name(.) = 'h')"> |
<xsl:if test = "not(name(.) = 'angle')"> |
<xsl:if test="not(name(.) = 'x')"> |
<xsl:if test="not(name(.) = 'y')"> |
<xsl:if test="not(name(.) = 'w')"> |
<xsl:if test="not(name(.) = 'h')"> |
<xsl:if test="not(name(.) = 'angle')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
148,14 → 193,15 |
</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:for-each> |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'COORDS')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'COORDS')"> |
<xsl:apply-templates select="." /> |
</xsl:if> |
</xsl:for-each> |
</xsl:element> |
164,6 → 210,13 |
<!-- get information of used polyline out of child 'POLYLINE' --> |
<xsl:for-each select="POLYLINE"> |
<xsl:element name="POLYLINE"> |
<!-- copy all attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- get coordinates --> |
<xsl:for-each select="COORDS"> |
<xsl:element name="COORDS"> |
174,8 → 227,8 |
<xsl:value-of select="@y" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = 'x')"> |
<xsl:if test = "not(name(.) = 'y')"> |
<xsl:if test="not(name(.) = 'x')"> |
<xsl:if test="not(name(.) = 'y')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
182,14 → 235,15 |
</xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:for-each> |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'COORDS')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'COORDS')"> |
<xsl:apply-templates select="." /> |
</xsl:if> |
</xsl:for-each> |
</xsl:element> |
197,10 → 251,10 |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'RECTANGLE')"> |
<xsl:if test = "not(name(.) = 'ELLIPSE')"> |
<xsl:if test = "not(name(.) = 'POLYLINE')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'RECTANGLE')"> |
<xsl:if test="not(name(.) = 'ELLIPSE')"> |
<xsl:if test="not(name(.) = 'POLYLINE')"> |
<xsl:apply-templates select="." /> |
</xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
|
217,7 → 271,7 |
</xsl:attribute> |
<!-- copy all other attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = ('image'))"> |
<xsl:if test="not(name(.) = ('image'))"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
228,6 → 282,13 |
<!-- get information of used rectangle out of child 'RECTANGLE' --> |
<xsl:for-each select="RECTANGLE"> |
<xsl:element name="RECTANGLE"> |
<!-- copy all attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- get coordinates --> |
<xsl:for-each select="COORDS"> |
<xsl:element name="COORDS"> |
244,10 → 305,10 |
<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(.) = 'w')"> |
<xsl:if test = "not(name(.) = 'h')"> |
<xsl:if test="not(name(.) = 'x')"> |
<xsl:if test="not(name(.) = 'y')"> |
<xsl:if test="not(name(.) = 'w')"> |
<xsl:if test="not(name(.) = 'h')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
254,8 → 315,12 |
</xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:for-each> |
<xsl:for-each select="COORD_DATA"> |
<xsl:element name="COORDS"> |
<!-- Insert an attribute which saves the original name of node, |
cause all nodes which contain data are transformed to a |
"COORDS" node. This extra information is used in back- |
263,10 → 328,7 |
<xsl:attribute name="XMLEditorSavedNameOfNode"> |
<xsl:value-of select="name(.)" /> |
</xsl:attribute> |
</xsl:element> |
</xsl:for-each> |
<xsl:for-each select="COORD_DATA"> |
<xsl:element name="COORDS"> |
|
<xsl:attribute name="x"> |
<xsl:value-of select="@x_pos" /> |
</xsl:attribute> |
280,10 → 342,10 |
<xsl:value-of select="@height" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = 'x_pos')"> |
<xsl:if test = "not(name(.) = 'y_pos')"> |
<xsl:if test = "not(name(.) = 'width')"> |
<xsl:if test = "not(name(.) = 'height')"> |
<xsl:if test="not(name(.) = 'x_pos')"> |
<xsl:if test="not(name(.) = 'y_pos')"> |
<xsl:if test="not(name(.) = 'width')"> |
<xsl:if test="not(name(.) = 'height')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
290,22 → 352,16 |
</xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
<!-- Insert an attribute which saves the original name of node, |
cause all nodes which contain data are transformed to a |
"COORDS" node. This extra information is used in back- |
transformation to restore the original name. --> |
<xsl:attribute name="XMLEditorSavedNameOfNode"> |
<xsl:value-of select="name(.)" /> |
</xsl:attribute> |
</xsl:element> |
</xsl:for-each> |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'COORDS')"> |
<xsl:if test = "not(name(.) = 'COORD_DATA')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'COORDS')"> |
<xsl:if test="not(name(.) = 'COORD_DATA')"> |
<xsl:apply-templates select="." /> |
</xsl:if></xsl:if> |
</xsl:for-each> |
</xsl:element> |
314,6 → 370,13 |
<!-- get information of used ellipse out of child 'ELLIPSE' --> |
<xsl:for-each select="ELLIPSE"> |
<xsl:element name="ELLIPSE"> |
<!-- copy all attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- get coordinates --> |
<xsl:for-each select="COORDS"> |
<xsl:element name="COORDS"> |
333,11 → 396,11 |
<xsl:value-of select="@angle" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = 'x')"> |
<xsl:if test = "not(name(.) = 'y')"> |
<xsl:if test = "not(name(.) = 'w')"> |
<xsl:if test = "not(name(.) = 'h')"> |
<xsl:if test = "not(name(.) = 'angle')"> |
<xsl:if test="not(name(.) = 'x')"> |
<xsl:if test="not(name(.) = 'y')"> |
<xsl:if test="not(name(.) = 'w')"> |
<xsl:if test="not(name(.) = 'h')"> |
<xsl:if test="not(name(.) = 'angle')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
344,14 → 407,15 |
</xsl:if></xsl:if></xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:for-each> |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'COORDS')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'COORDS')"> |
<xsl:apply-templates select="." /> |
</xsl:if> |
</xsl:for-each> |
</xsl:element> |
360,6 → 424,13 |
<!-- get information of used polyline out of child 'POLYLINE' --> |
<xsl:for-each select="POLYLINE"> |
<xsl:element name="POLYLINE"> |
<!-- copy all attributes --> |
<xsl:for-each select="attribute::*"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:for-each> |
|
<!-- get coordinates --> |
<xsl:for-each select="COORDS"> |
<xsl:element name="COORDS"> |
370,8 → 441,8 |
<xsl:value-of select="@y" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test = "not(name(.) = 'x')"> |
<xsl:if test = "not(name(.) = 'y')"> |
<xsl:if test="not(name(.) = 'x')"> |
<xsl:if test="not(name(.) = 'y')"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
378,14 → 449,15 |
</xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:copy-of select="self::node()" /> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:for-each> |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'COORDS')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'COORDS')"> |
<xsl:apply-templates select="." /> |
</xsl:if> |
</xsl:for-each> |
</xsl:element> |
393,10 → 465,10 |
|
<!-- copy all other childs --> |
<xsl:for-each select="node()"> |
<xsl:if test = "not(name(.) = 'RECTANGLE')"> |
<xsl:if test = "not(name(.) = 'ELLIPSE')"> |
<xsl:if test = "not(name(.) = 'POLYLINE')"> |
<xsl:copy-of select="self::node()" /> |
<xsl:if test="not(name(.) = 'RECTANGLE')"> |
<xsl:if test="not(name(.) = 'ELLIPSE')"> |
<xsl:if test="not(name(.) = 'POLYLINE')"> |
<xsl:apply-templates select="." /> |
</xsl:if></xsl:if></xsl:if> |
</xsl:for-each> |
|
403,5 → 475,56 |
</xsl:element> |
</xsl:template> |
|
<xsl:template match="PHOTO"> |
<xsl:element name="IMAGE"> |
<!-- set extra attribute saving the original name --> |
<xsl:attribute name="XMLEditorSavedNameOfNode"> |
<xsl:value-of select="'PHOTO'" /> |
</xsl:attribute> |
|
<!-- work on attributes and childs --> |
<xsl:attribute name="name"> |
<xsl:value-of select="@label" /> |
</xsl:attribute> |
<xsl:attribute name="url"> |
<xsl:value-of select="@uri" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test="not(name(.) = ('label'))"> |
<xsl:if test="not(name(.) = ('uri'))"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:template> |
|
<xsl:template match="IMAGE"> |
<xsl:element name="IMAGE"> |
<!-- work on attributes and childs --> |
<xsl:attribute name="name"> |
<xsl:value-of select="@label" /> |
</xsl:attribute> |
<xsl:attribute name="url"> |
<xsl:value-of select="@uri" /> |
</xsl:attribute> |
<xsl:for-each select="attribute::*"> |
<xsl:if test="not(name(.) = ('label'))"> |
<xsl:if test="not(name(.) = ('uri'))"> |
<xsl:attribute name="{name(.)}"> |
<xsl:value-of select="self::node()" /> |
</xsl:attribute> |
</xsl:if></xsl:if> |
</xsl:for-each> |
<xsl:for-each select="node()"> |
<xsl:apply-templates select="." /> |
</xsl:for-each> |
</xsl:element> |
</xsl:template> |
|
|
</xsl:stylesheet> |