xsl-list
[Top] [All Lists]

Re: [xsl] Unrequested stdout output

2016-12-21 10:08:00
The rule in the spec is that a principal result document is written if either 
(a) there is no secondary result document, or (b) the raw result of the initial 
template is a non-empty sequence. My guess would be that in your case the raw 
result contains some whitespace text nodes.

I usually avoid the problem by sending the principal output to dummy.xml and 
ignoring it: that's easier than worrying about where the pesky text nodes are 
coming from.

Michael Kay
Saxonica


On 21 Dec 2016, at 14:14, Mark Wilson mark(_at_)knihtisk(_dot_)org 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

I build one of my websites (www.cpslib.org) using a Windows batch file that 
has 45 distinct steps (I have never learned XProc and am 77 years old so 
maybe never will). Even though I am using <xsl:result-document> in the style 
sheet, the characters
   <?xml version="1.0" encoding="UTF-8"?>
appear at stdout.  The document itself is written to file as specified in 
result-document.

I have greatly simplified the batch file, XML document, and the stylesheet, 
but the stdout output still appears when I run the batch file. I have several 
other stylesheets in the batch file that use result-document. Some exhibit 
this behavior, some do not.

I am unsure if this is an artifact of Saxon 97, the batch file process ,or my 
code.  Any help?
Mark

Batch file:
set SAXON_HOME=C:\saxon97
set SAXON_JAR=%SAXON_HOME%\saxon9he.jar
java -jar c:\saxon97\saxon9he.jar   work\text.xml xslt\071a-get-words.xsl

XML document (text.xml)
<?xml version="1.0" encoding="UTF-8"?>
<List>
  <Set lang="latin">
     <Text data="Lynx lynx" pofis-number="817" latin-original="Lynx lynx"
           text-location="coupon"
           domain="cr"
           year="2014"/>
  </Set>
</List>

XSLT stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; exclude-result-prefixes="xs" 
version="2.0">

 <xsl:output indent="yes"/>

 <xsl:template match="List">
   <xsl:apply-templates/>
 </xsl:template>

 <xsl:template match="Set">
   <xsl:if test="@lang eq 'latin'">
     <xsl:result-document href="work/latin-words.xml">
       <List>
         <xsl:apply-templates/>
       </List>
     </xsl:result-document>
   </xsl:if>

 </xsl:template>

 <xsl:template match="Text">
   <xsl:variable name="data" select="@data"/>
   <xsl:variable name="eng" select="@eng-original"/>
   <xsl:variable name="czech" select="@czech-original"/>
   <xsl:variable name="latin" select="@latin-original"/>
   <!-- Is the text on the stamp or elsewhere? -->
   <xsl:variable name="type" select="if(@text-location) then @text-location 
else 'stamp'"/>
   <xsl:variable name="domain" select="@domain"/>
   <xsl:variable name="year" select="@year"/>
   <xsl:variable name="pofis-prefix" select="@pofis-prefix"/>
   <xsl:variable name="pofis-number" select="@pofis-number"/>
   <xsl:variable name="pofis-suffix" select="@pofis-suffix"/>

   <!--walk over each distinct value setting that value as the current node-->
   <xsl:choose>

     <!-- Latin word list  -->
     <xsl:when test="parent::Set/@lang eq 'latin'">
       <xsl:for-each select="distinct-values(tokenize(lower-case(@data), 
'\s+'))">
         <xsl:variable name="initial-letter" select="upper-case(substring(., 
1, 1))"/>
         <xsl:variable name="sort-word"
           select="concat($initial-letter, substring(., 2, string-length(.) 
-1))"/>
         <xsl:choose>
           <!-- Discard numbers -->
           <xsl:when test="number(substring-before(., '.'))"/>
           <xsl:otherwise>
             <Word word="{.}" sort-word="{$sort-word}" latin="{$latin}" 
domain="{$domain}"
               year="{$year}" pofis-prefix="{$pofis-prefix}" 
pofis-number="{$pofis-number}"
               pofis-suffix="{$pofis-suffix}" type="{$type}"/>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:for-each>
     </xsl:when>
   </xsl:choose>
 </xsl:template>

</xsl:stylesheet>



--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>