1<?xml version="1.0"?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 3 4 <!-- FileName: node15 --> 5 <!-- Document: http://www.w3.org/TR/xpath --> 6 <!-- DocVersion: 19991116 --> 7 <!-- Section: 2.3 --> 8 <!-- AdditionalSpec: XSLT 5.2 --> 9 <!-- Creator: David Marston --> 10 <!-- Purpose: Test for node() in match patterns. Default axis is child. --> 11 12<xsl:template match="/doc"> 13 <out> 14 <xsl:apply-templates select="*|@*|comment()|processing-instruction()|text()"/> 15 </out> 16</xsl:template> 17 18<xsl:template match="node()"> 19 <xsl:text>N-</xsl:text> 20 <xsl:choose> 21 <xsl:when test="name(.)!=''"> 22 <xsl:text>named:</xsl:text><xsl:value-of select="name()"/><xsl:text>...</xsl:text> 23 </xsl:when> 24 <xsl:when test=".!=''"> 25 <xsl:text>content:</xsl:text><xsl:value-of select="."/> 26 </xsl:when> 27 <xsl:otherwise> 28 <xsl:text>UNKNOWN</xsl:text> 29 </xsl:otherwise> 30 </xsl:choose> 31 <xsl:apply-templates select="@*"/> 32 <xsl:apply-templates/> 33 <xsl:text>, 34</xsl:text> 35</xsl:template> 36 37<xsl:template match="attribute::*" priority="-1"> 38 <xsl:text>A:</xsl:text><xsl:value-of select="name()"/> 39 <xsl:text> 40 </xsl:text> 41</xsl:template> 42 43<xsl:template match="text()" priority="-2"><!-- Override built-in template --> 44 <xsl:text>Incorrect text match:</xsl:text><xsl:value-of select="."/> 45</xsl:template> 46 47 48 <!-- 49 * Licensed to the Apache Software Foundation (ASF) under one 50 * or more contributor license agreements. See the NOTICE file 51 * distributed with this work for additional information 52 * regarding copyright ownership. The ASF licenses this file 53 * to you under the Apache License, Version 2.0 (the "License"); 54 * you may not use this file except in compliance with the License. 55 * You may obtain a copy of the License at 56 * 57 * http://www.apache.org/licenses/LICENSE-2.0 58 * 59 * Unless required by applicable law or agreed to in writing, software 60 * distributed under the License is distributed on an "AS IS" BASIS, 61 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 62 * See the License for the specific language governing permissions and 63 * limitations under the License. 64 --> 65 66</xsl:stylesheet> 67