comparison software/mpdl-services/mpiwg-mpdl-xml/build/classes/de/mpg/mpiwg/berlin/mpdl/xml/transform/getFragment.xsl @ 23:e845310098ba

diverse Korrekturen
author Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de>
date Tue, 27 Nov 2012 12:35:19 +0100
parents dc5e9fcb3fdc
children
comparison
equal deleted inserted replaced
22:6a45a982c333 23:e845310098ba
10 </xsl:function> 10 </xsl:function>
11 11
12 <xsl:output method="xml" encoding="utf-8"/> 12 <xsl:output method="xml" encoding="utf-8"/>
13 13
14 <!-- ms1Name and ms2Name have to be given without namespace: e.g. "pb" --> 14 <!-- ms1Name and ms2Name have to be given without namespace: e.g. "pb" -->
15 <xsl:param name="xmlFileName"></xsl:param>
16 <xsl:param name="ms1Name"></xsl:param> 15 <xsl:param name="ms1Name"></xsl:param>
17 <xsl:param name="ms1Position"></xsl:param> 16 <xsl:param name="ms1Position"></xsl:param>
18 <xsl:param name="ms2Name"></xsl:param> 17 <xsl:param name="ms2Name"></xsl:param>
19 <xsl:param name="ms2Position"></xsl:param> 18 <xsl:param name="ms2Position"></xsl:param>
20 19
23 <xsl:variable name="ms1" select="saxon:evaluate($ms1XPath)" xmlns:saxon="http://saxon.sf.net/"/> 22 <xsl:variable name="ms1" select="saxon:evaluate($ms1XPath)" xmlns:saxon="http://saxon.sf.net/"/>
24 <xsl:variable name="ms2" select="saxon:evaluate($ms2XPath)" xmlns:saxon="http://saxon.sf.net/"/> 23 <xsl:variable name="ms2" select="saxon:evaluate($ms2XPath)" xmlns:saxon="http://saxon.sf.net/"/>
25 <xsl:variable name="ms1Ancestors" select="$ms1/ancestor::*"/> 24 <xsl:variable name="ms1Ancestors" select="$ms1/ancestor::*"/>
26 <xsl:variable name="ms2Ancestors" select="$ms2/ancestor::*"/> 25 <xsl:variable name="ms2Ancestors" select="$ms2/ancestor::*"/>
27 26
27 <!-- all elements between the milestone elements and also the ancestor elements (for filling the node path to the root) -->
28 <xsl:template match="element()[local-name() != $ms1Name and local-name() != $ms2Name]"> 28 <xsl:template match="element()[local-name() != $ms1Name and local-name() != $ms2Name]">
29 <xsl:choose> 29 <xsl:choose>
30 <xsl:when test="(. >> $ms1 or fn:contains($ms1Ancestors, .)) and ($ms2 >> . or fn:contains($ms2Ancestors, .))"> 30 <xsl:when test="(. >> $ms1 or fn:contains($ms1Ancestors, .)) and ($ms2 >> . or fn:contains($ms2Ancestors, .))">
31 <xsl:element name="{local-name(.)}"><xsl:apply-templates/></xsl:element> 31 <xsl:element name="{local-name(.)}"><xsl:copy-of select="@*"></xsl:copy-of><xsl:apply-templates/></xsl:element>
32 </xsl:when> 32 </xsl:when>
33 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> 33 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
34 </xsl:choose>
35 </xsl:template>
36
37 <!-- the two milestone elements -->
38 <xsl:template match="element()[local-name() = $ms1Name or local-name() = $ms2Name]">
39 <xsl:choose>
40 <xsl:when test=". is $ms1">
41 <xsl:element name="{local-name(.)}"><xsl:copy-of select="@*"></xsl:copy-of></xsl:element>
42 </xsl:when>
43 <xsl:when test=". is $ms2">
44 <xsl:element name="{local-name(.)}"><xsl:copy-of select="@*"></xsl:copy-of></xsl:element>
45 </xsl:when>
46 <xsl:otherwise></xsl:otherwise>
34 </xsl:choose> 47 </xsl:choose>
35 </xsl:template> 48 </xsl:template>
36 49
37 <xsl:template match="attribute()|text()|comment()|processing-instruction()"> 50 <xsl:template match="attribute()|text()|comment()|processing-instruction()">
38 <xsl:choose> 51 <xsl:choose>
41 </xsl:when> 54 </xsl:when>
42 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise> 55 <xsl:otherwise><xsl:apply-templates/></xsl:otherwise>
43 </xsl:choose> 56 </xsl:choose>
44 </xsl:template> 57 </xsl:template>
45 58
46 <xsl:template match="element()[local-name() = $ms1Name or local-name() = $ms2Name]">
47 <xsl:choose>
48 <xsl:when test=". is $ms1">
49 <xsl:element name="{local-name(.)}"><xsl:copy-of select="@*"></xsl:copy-of></xsl:element>
50 </xsl:when>
51 <xsl:when test=". is $ms2">
52 <xsl:element name="{local-name(.)}"><xsl:copy-of select="@*"></xsl:copy-of></xsl:element>
53 </xsl:when>
54 <xsl:otherwise></xsl:otherwise>
55 </xsl:choose>
56 </xsl:template>
57
58 </xsl:stylesheet> 59 </xsl:stylesheet>