xref: /aosp_15_r20/external/apache-xml/test/tests/contrib/xsltc/mk/mk043.xsl (revision 1212f9a0ffdc28482b8821715d2222bf16dc14e2)
1<?xml version="1.0" encoding="iso-8859-1"?>
2<xsl:transform
3 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4 version="1.0"
5>
6
7  <!-- Test FileName: mk043.xsl -->
8  <!-- Source Attribution:
9       This test was written by Michael Kay and is taken from
10       'XSLT Programmer's Reference' published by Wrox Press Limited in 2000;
11       ISBN 1-861003-12-9; copyright Wrox Press Limited 2000; all rights reserved.
12       Now updated in the second edition (ISBN 1861005067), http://www.wrox.com.
13       No part of this book may be reproduced, stored in a retrieval system or
14       transmitted in any form or by any means - electronic, electrostatic, mechanical,
15       photocopying, recording or otherwise - without the prior written permission of
16       the publisher, except in the case of brief quotations embodied in critical articles or reviews.
17  -->
18  <!-- Example: any xml, list-elements.xsl -->
19  <!-- Chapter/Page: 7-489 -->
20  <!-- Purpose: Listing the element names that appear in a doc -->
21
22<xsl:template match="/">
23<html><body>
24<h1>Table of elements</h1>
25<table border="1" cellpadding="5">
26<tr><td>Element</td><td>Prefix</td><td>Local name</td><td>Namespace URI</td></tr>
27    <xsl:apply-templates select="//*">
28         <xsl:sort select="namespace-uri()"/>
29         <xsl:sort select="local-name()"/>
30    </xsl:apply-templates>
31</table></body></html>
32</xsl:template>
33
34<xsl:template match="*">
35     <xsl:variable name="prefix">
36        <xsl:choose>
37        <xsl:when test="contains(name(), ':')">
38           <xsl:value-of select="substring-before(name(),':')"/>
39        </xsl:when>
40        <xsl:otherwise/>
41        </xsl:choose>
42     </xsl:variable>
43     <tr>
44     <td><xsl:value-of select="name()"/></td>
45     <td><xsl:value-of select="$prefix"/></td>
46     <td><xsl:value-of select="local-name()"/></td>
47     <td><xsl:value-of select="namespace-uri()"/></td>
48     </tr>
49</xsl:template>
50
51  <!--
52   * Licensed to the Apache Software Foundation (ASF) under one
53   * or more contributor license agreements. See the NOTICE file
54   * distributed with this work for additional information
55   * regarding copyright ownership. The ASF licenses this file
56   * to you under the Apache License, Version 2.0 (the  "License");
57   * you may not use this file except in compliance with the License.
58   * You may obtain a copy of the License at
59   *
60   *     http://www.apache.org/licenses/LICENSE-2.0
61   *
62   * Unless required by applicable law or agreed to in writing, software
63   * distributed under the License is distributed on an "AS IS" BASIS,
64   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65   * See the License for the specific language governing permissions and
66   * limitations under the License.
67  -->
68
69</xsl:transform>
70