xref: /aosp_15_r20/external/apache-xml/test/tests/conf/idkey/idkey50.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1*1212f9a0SAndroid Build Coastguard Worker<?xml version="1.0"?>
2*1212f9a0SAndroid Build Coastguard Worker<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3*1212f9a0SAndroid Build Coastguard Worker     version='1.0'
4*1212f9a0SAndroid Build Coastguard Worker     xmlns:x="http://namespaces.ogbuji.net/articles" exclude-result-prefixes="x">
5*1212f9a0SAndroid Build Coastguard Worker
6*1212f9a0SAndroid Build Coastguard Worker  <!-- FileName: idkey50 -->
7*1212f9a0SAndroid Build Coastguard Worker  <!-- Document: http://www.w3.org/TR/xslt -->
8*1212f9a0SAndroid Build Coastguard Worker  <!-- DocVersion: 19991116 -->
9*1212f9a0SAndroid Build Coastguard Worker  <!-- Section: 12.2 -->
10*1212f9a0SAndroid Build Coastguard Worker  <!-- Creator: Uche Ogbuji, adapted by David Marston -->
11*1212f9a0SAndroid Build Coastguard Worker  <!-- Purpose: Test combination of key() and document() reading from stylesheet. -->
12*1212f9a0SAndroid Build Coastguard Worker  <!-- Elaboration: "Look-up table 1.6 is worth a close look because it uses an advanced XSLT
13*1212f9a0SAndroid Build Coastguard Worker    technique. It builds up the lookup-table right in the stylesheet, using a distinct namespace.
14*1212f9a0SAndroid Build Coastguard Worker    You can see the x:ns-to-binding elements right below the key. If you are familiar with keys,
15*1212f9a0SAndroid Build Coastguard Worker    you are aware that they define indices that will be built on the nodes in the original source
16*1212f9a0SAndroid Build Coastguard Worker    document that match the pattern in the match attribute. What is not as well known is that
17*1212f9a0SAndroid Build Coastguard Worker    every time an additional source document is loaded with the XSLT document() function, all keys
18*1212f9a0SAndroid Build Coastguard Worker    are applied to it as well. The xsl:variable...uses a special form of document() call to load
19*1212f9a0SAndroid Build Coastguard Worker    the stylesheet itself as an additional source document. Thus the nodes in the stylesheet that
20*1212f9a0SAndroid Build Coastguard Worker    match the ns-to-binding are indexed. This is a very useful technique for setting up a look-up
21*1212f9a0SAndroid Build Coastguard Worker    table without having to hack at the source document or depend on an additional file." -->
22*1212f9a0SAndroid Build Coastguard Worker
23*1212f9a0SAndroid Build Coastguard Worker<xsl:output method='xml'/>
24*1212f9a0SAndroid Build Coastguard Worker
25*1212f9a0SAndroid Build Coastguard Worker  <!-- Lookup table 1.6: WSDL binding types -->
26*1212f9a0SAndroid Build Coastguard Worker  <xsl:key name='ns-to-binding' match='x:ns-to-binding' use='@binding'/>
27*1212f9a0SAndroid Build Coastguard Worker  <x:ns-to-binding uri='http://schemas.xmlsoap.org/wsdl/soap/' binding='SOAP'/>
28*1212f9a0SAndroid Build Coastguard Worker  <x:ns-to-binding uri='http://schemas.xmlsoap.org/wsdl/mime/' binding='MIME'/>
29*1212f9a0SAndroid Build Coastguard Worker  <x:ns-to-binding uri='http://schemas.xmlsoap.org/wsdl/http/' binding='HTTP'/>
30*1212f9a0SAndroid Build Coastguard Worker
31*1212f9a0SAndroid Build Coastguard Worker<xsl:template match='doc'>
32*1212f9a0SAndroid Build Coastguard Worker  <out>
33*1212f9a0SAndroid Build Coastguard Worker    <xsl:apply-templates/>
34*1212f9a0SAndroid Build Coastguard Worker  </out>
35*1212f9a0SAndroid Build Coastguard Worker</xsl:template>
36*1212f9a0SAndroid Build Coastguard Worker
37*1212f9a0SAndroid Build Coastguard Worker<xsl:template match="bind">
38*1212f9a0SAndroid Build Coastguard Worker  <bound>
39*1212f9a0SAndroid Build Coastguard Worker    <xsl:variable name="lookup" select="."/>
40*1212f9a0SAndroid Build Coastguard Worker    <xsl:value-of select="$lookup"/><xsl:text>- </xsl:text>
41*1212f9a0SAndroid Build Coastguard Worker    <xsl:for-each select="document('')"><!-- Switch context so key reads from stylesheet -->
42*1212f9a0SAndroid Build Coastguard Worker      <xsl:value-of select="key('ns-to-binding',$lookup)/@uri"/>
43*1212f9a0SAndroid Build Coastguard Worker    </xsl:for-each>
44*1212f9a0SAndroid Build Coastguard Worker  </bound>
45*1212f9a0SAndroid Build Coastguard Worker</xsl:template>
46*1212f9a0SAndroid Build Coastguard Worker
47*1212f9a0SAndroid Build Coastguard Worker
48*1212f9a0SAndroid Build Coastguard Worker  <!--
49*1212f9a0SAndroid Build Coastguard Worker   * Licensed to the Apache Software Foundation (ASF) under one
50*1212f9a0SAndroid Build Coastguard Worker   * or more contributor license agreements. See the NOTICE file
51*1212f9a0SAndroid Build Coastguard Worker   * distributed with this work for additional information
52*1212f9a0SAndroid Build Coastguard Worker   * regarding copyright ownership. The ASF licenses this file
53*1212f9a0SAndroid Build Coastguard Worker   * to you under the Apache License, Version 2.0 (the  "License");
54*1212f9a0SAndroid Build Coastguard Worker   * you may not use this file except in compliance with the License.
55*1212f9a0SAndroid Build Coastguard Worker   * You may obtain a copy of the License at
56*1212f9a0SAndroid Build Coastguard Worker   *
57*1212f9a0SAndroid Build Coastguard Worker   *     http://www.apache.org/licenses/LICENSE-2.0
58*1212f9a0SAndroid Build Coastguard Worker   *
59*1212f9a0SAndroid Build Coastguard Worker   * Unless required by applicable law or agreed to in writing, software
60*1212f9a0SAndroid Build Coastguard Worker   * distributed under the License is distributed on an "AS IS" BASIS,
61*1212f9a0SAndroid Build Coastguard Worker   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
62*1212f9a0SAndroid Build Coastguard Worker   * See the License for the specific language governing permissions and
63*1212f9a0SAndroid Build Coastguard Worker   * limitations under the License.
64*1212f9a0SAndroid Build Coastguard Worker  -->
65*1212f9a0SAndroid Build Coastguard Worker
66*1212f9a0SAndroid Build Coastguard Worker</xsl:stylesheet>
67