Project

Profile

Help

Bug #4523 » bug_demo.xslt

Debbie Lockett, 2020-04-20 13:16

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ixsl="http://saxonica.com/ns/interactiveXSLT"
extension-element-prefixes="ixsl"
xpath-default-namespace="http://www.wwp.neu.edu/temp/ns"
xmlns="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="#all" >
<!-- Since I'm debugging, be explicit: -->
<xsl:mode name="content_only" on-no-match="text-only-copy"/>
<xsl:variable name="input_doc" select="/"/>
<xsl:template match="/">
<xsl:variable name="all_content">
<xsl:apply-templates select="$input_doc/demo/text" mode="content_only"/>
</xsl:variable>
<xsl:variable name="ac_normalized" select="normalize-space($all_content)"/>
<xsl:variable name="all_tokens" select="tokenize( $ac_normalized,'&#x20;')"/>
<xsl:variable name="num_tokens" select="count( $all_tokens )"/>
<!-- [ matches( .,'\p{L}')] -->
<xsl:choose>
<xsl:when test="function-available('ixsl:location')">
<xsl:message select="'Debug: in SEF, right?'"/>
<xsl:result-document href="#bug_demo" method="ixsl:replace-content">
<xsl:value-of select="$num_tokens"/>
</xsl:result-document>
</xsl:when>
<xsl:otherwise>
<xsl:message select="'Debug: on cmdline, right?'"/>
<xsl:result-document href="/tmp/bug_demo.txt" method="text">
<xsl:value-of select="$num_tokens"/>
</xsl:result-document>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<!--
For the purposes of the bug, it does not matter whether the
following template is present or not. I just show it to give
a flavor of why I am applying templates to <text>, rather
than just taking its string value.
-->
<xsl:template mode="content_only"
match="elision|sic|expan|reg|mw|note[@type=('editorial','temp','WWP')]"/>
</xsl:stylesheet>
(3-3/3)