comparison software/eXist/webapp/mpdl/presentation/insertExternalElements.xsl @ 17:7e883ce72fec

diverse Fehlerbehebungen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Sep 2011 16:41:15 +0200
parents e99964f390e4
children
comparison
equal deleted inserted replaced
16:257f67be5c00 17:7e883ce72fec
8 > 8 >
9 9
10 <xsl:output method="xml" encoding="utf-8"/> 10 <xsl:output method="xml" encoding="utf-8"/>
11 <xsl:output name="myXml" indent="yes" omit-xml-declaration="yes"/> 11 <xsl:output name="myXml" indent="yes" omit-xml-declaration="yes"/>
12 12
13 <xsl:variable name="options" select="/result/options"/>
13 <xsl:variable name="externalElements" select="/result/externalElements"/> 14 <xsl:variable name="externalElements" select="/result/externalElements"/>
14 <xsl:variable name="xpointer" select="/result/xpointer"/> 15 <xsl:variable name="xpointer" select="/result/xpointer"/>
15 <xsl:variable name="xpointerPath"> 16 <xsl:variable name="xpointerPath">
16 <xsl:choose> 17 <xsl:choose>
17 <xsl:when test="contains($xpointer, '/range(')"> 18 <xsl:when test="contains($xpointer, '/range(')">
69 <xsl:apply-templates/> 70 <xsl:apply-templates/>
70 </xsl:template> 71 </xsl:template>
71 <xsl:template match="fragment"> 72 <xsl:template match="fragment">
72 <xsl:apply-templates/> 73 <xsl:apply-templates/>
73 </xsl:template> 74 </xsl:template>
75 <xsl:template match="options"></xsl:template>
74 <xsl:template match="externalElements"></xsl:template> 76 <xsl:template match="externalElements"></xsl:template>
75 <xsl:template match="xpointer"></xsl:template> 77 <xsl:template match="xpointer"></xsl:template>
76 78
77 <xsl:template match="attribute()|text()|comment()|processing-instruction()"> 79 <xsl:template match="attribute()|text()|comment()|processing-instruction()">
78 <xsl:copy> 80 <xsl:copy>
79 <xsl:apply-templates select="attribute()|element()|text()|comment()|processing-instruction()"/> 81 <xsl:apply-templates select="attribute()|element()|text()|comment()|processing-instruction()"/>
80 </xsl:copy> 82 </xsl:copy>
81 </xsl:template> 83 </xsl:template>
82 84
83 <xsl:template match="element()"> 85 <xsl:template match="element()">
86 <xsl:variable name="identifier" select="@*:id"/>
84 <xsl:variable name="elemXmlNodeIdTmp" select="saxon:path(.)"/> 87 <xsl:variable name="elemXmlNodeIdTmp" select="saxon:path(.)"/>
85 <xsl:variable name="elemXmlNodeId" select="concat('/', substring-after(substring-after(substring-after($elemXmlNodeIdTmp, '/'), '/'), '/'))"/> 88 <xsl:variable name="elemXmlNodeId" select="concat('/', substring-after(substring-after(substring-after($elemXmlNodeIdTmp, '/'), '/'), '/'))"/>
86 <xsl:variable name="extElemXmlNodeIds" select="$externalElements//@xmlNodeId"/> 89 <xsl:variable name="extElemXmlNodeIds" select="$externalElements//@xmlNodeId"/>
87 <!-- Bug: if there are more than one external node at the same position, index-of delivers an error: ToDo: handle more than one external nodes at one position --> 90 <!-- Bug: if there are more than one external node at the same position, index-of delivers an error: ToDo: handle more than one external nodes at one position -->
88 <xsl:variable name="extElemIndex" select="index-of($extElemXmlNodeIds, $elemXmlNodeId)"/> 91 <xsl:variable name="extElemIndex" select="index-of($extElemXmlNodeIds, $elemXmlNodeId)"/>
127 <xsl:value-of select="''"/> 130 <xsl:value-of select="''"/>
128 </xsl:otherwise> 131 </xsl:otherwise>
129 </xsl:choose> 132 </xsl:choose>
130 </xsl:variable> 133 </xsl:variable>
131 <xsl:variable name="thisElement"> 134 <xsl:variable name="thisElement">
132 <xsl:copy> 135 <xsl:choose>
133 <xsl:apply-templates select="attribute()"/> 136 <xsl:when test="contains($options, 'withIdentifier')">
134 <xsl:attribute name="xmlNodeId"> 137 <xsl:copy>
135 <xsl:value-of select="$elemXmlNodeId"/> 138 <xsl:apply-templates select="attribute()"/>
136 </xsl:attribute> 139 <xsl:if test="not(empty($identifier))">
137 <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/> 140 <xsl:attribute name="identifier">
138 </xsl:copy> 141 <xsl:value-of select="$identifier"/>
142 </xsl:attribute>
143 </xsl:if>
144 <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/>
145 </xsl:copy>
146 </xsl:when>
147 <xsl:otherwise>
148 <xsl:copy>
149 <xsl:apply-templates select="attribute()"/>
150 <xsl:attribute name="xmlNodeId">
151 <xsl:value-of select="$elemXmlNodeId"/>
152 </xsl:attribute>
153 <xsl:apply-templates select="element()|text()|comment()|processing-instruction()"/>
154 </xsl:copy>
155 </xsl:otherwise>
156 </xsl:choose>
139 </xsl:variable> 157 </xsl:variable>
140 <xsl:if test="$extElemXPointerPoint = '.0'"> 158 <xsl:if test="$extElemXPointerPoint = '.0'">
141 <xsl:sequence select="$extElemContent"/> 159 <xsl:sequence select="$extElemContent"/>
142 </xsl:if> 160 </xsl:if>
143 <xsl:if test="$extElemXPointerPointInt &gt;= 0"> 161 <xsl:if test="$extElemXPointerPointInt &gt;= 0">