Re: [xsl] Automatically copying an element's attributes and their values

Subject: Re: [xsl] Automatically copying an element's attributes and their values
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 8 Sep 2003 15:18:22 +0100

running your stylesheet I get:

$ saxon att.xml att.xsl
Error at xsl:choose on line 44 of file:/c://att.xsl:
  Only xsl:when and xsl:otherwise are allowed here
Error at xsl:choose on line 44 of file:/c://att.xsl:
  Only xsl:when and xsl:otherwise are allowed here
Error at xsl:choose on line 44 of file:/c://att.xsl:
  Only xsl:when and xsl:otherwise are allowed here
Error at xsl:choose on line 101 of file:/c://att.xsl:
  Only xsl:when and xsl:otherwise are allowed here
Error at xsl:choose on line 101 of file:/c://att.xsl:
  Only xsl:when and xsl:otherwise are allowed here
Error at xsl:choose on line 101 of file:/c://att.xsl:
  Only xsl:when and xsl:otherwise are allowed here
Transformation failed: Failed to compile stylesheet. 6 errors detected.


the reason being

   xml:space="preserve"

this means that white space in your stylesheet is not stripped and so
essentially acts as if it's surrounded with xsl:text
so
<xsl:choose>
<xsl:when test="@id">

is an error as there is non-ignored white space before the when

and

<ns0:acronym>
<xsl:copy-of select="@*"/>

is a recoverabvle error as there is already a (white) text node child of 
<ns0:acronym> added to the result so you can no longer add attributes.

removing xml:space from your stylesheet (and adding 
xsl:output indent="yes"
 for clarity)
I get:


<?xml version="1.0" encoding="utf-8"?>
<ns0:paper xmlns:ns0="http://www.dmsi-world.com/ns/paper"; xmlns:w="http://schemas.microsoft.com/office/word/ 2003/wordml" xmlns:wx="http://schemas.microsoft.com/office/word /2003/auxHint" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:sl="http://schemas.microsoft.com/schemaLibra ry/2003/core" xmlns:aml="http://schemas.microsoft.com/aml/2001/c ore" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C1488 2" xmlns:st1="urn:schemas-microsoft-com:office:smartt ags" id="" level="" area="" presdate="" prestime="">

   <ns0:para>
      <w:p>
         <w:pPr>
            <w:rPr>
               <w:rFonts w:cs="Arial"/>
               <w:sz-cs w:val="20"/>
            </w:rPr>
         </w:pPr>
         <w:r>
            <w:t>Some text here </w:t>
         </w:r>
         <ns0:acronym.grp>
            <ns0:acronym refid="IC">
               <w:r>
                  <w:rPr>
                     <w:rStyle w:val="Acronym"/>
                  </w:rPr>
                  <w:t>IC's</w:t>
               </w:r>
            </ns0:acronym>
            <ns0:expansion id="IC">
               <w:r>
                  <w:t> (Intelligence
Community)</w:t>
               </w:r>
            </ns0:expansion>
         </ns0:acronym.grp>
         <w:r>
            <w:t> more text goes
here </w:t>
         </w:r>
         <ns0:acronym.grp>
            <ns0:acronym refid="HTML">
               <w:r>
                  <w:rPr>
                     <w:rStyle w:val="Acronym"/>
                  </w:rPr>
                  <w:t>HTML</w:t>
               </w:r>
            </ns0:acronym>
            <ns0:expansion id="HTML">
               <w:r>
                  <w:t> (HyperText Markup
Language)</w:t>
               </w:r>
            </ns0:expansion>
         </ns0:acronym.grp>
         <w:r>
            <w:t> final bit of
text.</w:t>
         </w:r>
      </w:p>
   </ns0:para>

</ns0:paper>

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread