xref: /aosp_15_r20/external/apache-xml/test/tests/conf/idkey/idkey51.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0" encoding="UTF-8"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
4  <!-- FileName: idkey51 -->
5  <!-- Document: http://www.w3.org/TR/xslt -->
6  <!-- DocVersion: 19991116 -->
7  <!-- Section: 12.1 -->
8  <!-- Creator: David Marston -->
9  <!-- Purpose: Test two calls to generate-id() on the same file. All IDs should be
10    the same. If both filenames were given literally, the spec says that IDs must match.
11    Retrieving the name from the principal XML document should still clearly mean the
12    same file. Putting nodes in a variable is more of a gray area. -->
13
14<xsl:output method="xml" encoding="UTF-8" indent="no"/>
15
16<xsl:template match="doc">
17  <out>
18    <xsl:variable name="tn" select="document('idkey49a.xml')//doc/body/text()[1]" />
19    <xsl:choose>
20      <xsl:when test="generate-id(document('idkey49a.xml')//body) != generate-id(document(a)//body)">
21        <xsl:text>FAIL on body element: </xsl:text>
22        <xsl:value-of select="generate-id(document('idkey49c.xml')//body)"/><xsl:text>,  </xsl:text>
23        <xsl:value-of select="generate-id(document(a)//body)"/><xsl:text>&#10;</xsl:text>
24      </xsl:when>
25      <xsl:when test="generate-id(document('idkey49a.xml')//text()[1]) != generate-id(document(a)//text()[1])">
26        <xsl:text>FAIL on first text node: </xsl:text>
27        <xsl:value-of select="generate-id(document('idkey49c.xml')//text()[1])"/><xsl:text>,  </xsl:text>
28        <xsl:value-of select="generate-id(document(a)//text()[1])"/><xsl:text>&#10;</xsl:text>
29      </xsl:when>
30      <xsl:when test="generate-id(document('idkey49a.xml')//body/@att) != generate-id(document(a)//body/@att)">
31        <xsl:text>FAIL on body attribute: </xsl:text>
32        <xsl:value-of select="generate-id(document('idkey49c.xml')//body/@att)"/><xsl:text>,  </xsl:text>
33        <xsl:value-of select="generate-id(document(a)//body/@att)"/><xsl:text>&#10;</xsl:text>
34      </xsl:when>
35      <xsl:when test="generate-id(document('idkey49a.xml')//comment()[1]) != generate-id(document(a)//comment()[1])">
36        <xsl:text>FAIL on first comment node: </xsl:text>
37        <xsl:value-of select="generate-id(document('idkey49c.xml')//comment()[1])"/><xsl:text>,  </xsl:text>
38        <xsl:value-of select="generate-id(document(a)//comment()[1])"/><xsl:text>&#10;</xsl:text>
39      </xsl:when>
40      <!-- Now try the node in the variable -->
41      <xsl:when test="generate-id($tn) != generate-id(document(a)//doc/body/text()[1])">
42        <xsl:text>FAIL on inner text node: </xsl:text>
43        <xsl:value-of select="generate-id(document('idkey49c.xml')//text()[1])"/><xsl:text>,  </xsl:text>
44        <xsl:value-of select="generate-id(document(a)//text()[1])"/><xsl:text>&#10;</xsl:text>
45      </xsl:when>
46      <xsl:otherwise>
47        <xsl:text>Success</xsl:text>
48      </xsl:otherwise>
49    </xsl:choose>
50  </out>
51</xsl:template>
52
53
54  <!--
55   * Licensed to the Apache Software Foundation (ASF) under one
56   * or more contributor license agreements. See the NOTICE file
57   * distributed with this work for additional information
58   * regarding copyright ownership. The ASF licenses this file
59   * to you under the Apache License, Version 2.0 (the  "License");
60   * you may not use this file except in compliance with the License.
61   * You may obtain a copy of the License at
62   *
63   *     http://www.apache.org/licenses/LICENSE-2.0
64   *
65   * Unless required by applicable law or agreed to in writing, software
66   * distributed under the License is distributed on an "AS IS" BASIS,
67   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
68   * See the License for the specific language governing permissions and
69   * limitations under the License.
70  -->
71
72</xsl:stylesheet>
73