[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Automatically copying an element's attributes and

Subject: RE: Automatically copying an element's attributes and their values
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Mon, 8 Sep 2003 15:35:45 +0100
xmlns ns0
I removed the xml:space="preserve" from your stylesheet (because it
causes <xsl:choose> to have text child nodes, which are not allowed),
and added <xsl:output indent="yes" so I could see what was happening,
and it produced this:

<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/core"
xmlns:o="urn:schemas-microsoft-com:office:office"
xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"
xmlns:st1="urn:schemas-microsoft-com:office:smarttags" 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>

As far as I can see the attributes of the <ns0:acronym> element have
been copied correctly.

This was with Saxon 6.5.3.

Michael Kay



> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mary McRae
> Sent: 08 September 2003 14:35
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Automatically copying an element's 
> attributes and their values
> 
> 
> Sorry, I'm sure the xsl is a bit more than you
> expected. The attributes come through fine where I
> explicitly create them; but no attribute shows up
> on the acronym element where I've put in
> <xsl:copy-of select="@*"/>
> 
> Thanks again for any help!
> 
> Mary
> 
> --------
> 
> Test input snippet:
> <?xml version="1.0" encoding="utf-8"
> standalone="no"?>
> <paper xmlns="http://www.dmsi-world.com/ns/paper"
> id="" level="" area="" presdate="" prestime=""
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan
> ce"
> xsi:schemaLocation="http://www.dmsi-world.com/ns/p
> aper DMSi_paper.xsd">
> <para>Some text here <acronym.grp><acronym
> refid="IC">IC's</acronym><expansion
> id="IC">Intelligence
> Community</expansion></acronym.grp> more text goes
> here <acronym.grp><acronym
> refid="HTML">HTML</acronym><expansion
> id="HTML">HyperText Markup
> Language</expansion></acronym.grp> final bit of
> text.</para>
> </paper>
> 
> -------
> 
> Test xsl snippet:
> <?xml version="1.0" encoding="UTF-8"
> standalone="yes"?>
> <?mso-application progid="Word.Document"?>
> <xsl:stylesheet version="1.0"
>  
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>  
> xmlns:w="http://schemas.microsoft.com/office/word/
> 2003/wordml"
>  
> xmlns:wx="http://schemas.microsoft.com/office/word
> /2003/auxHint"
>    xmlns:ns0="http://www.dmsi-world.com/ns/paper"
>    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"
>    xml:space="preserve">
> 
> <xsl:template match="/">
> <ns0:paper id="{ns0:paper/@id}"
> level="{ns0:paper/@level}"
> area="{ns0:paper/@area}"
> presdate="{ns0:paper/@presdate}"
> prestime="{paper/@prestime}">
> <xsl:apply-templates/>
> </ns0:paper>
> </xsl:template>
> 
> <xsl:template match="ns0:para">
> <xsl:choose>
> <xsl:when test="@id">
> <ns0:para id="{@id}">
> <w:p>
> <w:pPr>
> <w:rPr>
> <w:rFonts w:cs="Arial"/>
> <w:sz-cs w:val="20"/>
> </w:rPr>
> </w:pPr>
> <xsl:apply-templates mode="para"/>
> </w:p>
> </ns0:para>
> </xsl:when>
> <xsl:otherwise>
> <ns0:para>
> <w:p>
> <w:pPr>
> <w:rPr>
> <w:rFonts w:cs="Arial"/>
> <w:sz-cs w:val="20"/>
> </w:rPr>
> </w:pPr>
> <xsl:apply-templates mode="para"/>
> </w:p>
> </ns0:para>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> 
> <xsl:template match="text()" mode="para">
> <w:r>
> <w:t><xsl:value-of select="."/></w:t>
> </w:r>
> </xsl:template>
> 
> <xsl:template match="ns0:acronym.grp" mode="para">
> <ns0:acronym.grp>
> <xsl:apply-templates/>
> </ns0:acronym.grp>
> </xsl:template>
> 
> <!-- testing version -->
> <xsl:template match="ns0:acronym">
> <ns0:acronym>
> <xsl:copy-of select="@*"/>
> <w:r>
> <w:rPr>
> <w:rStyle w:val="Acronym"/>
> </w:rPr>
> <w:t><xsl:apply-templates/></w:t>
> </w:r>
> </ns0:acronym>
> </xsl:template>
> <!-- end of test -->
> 
> <xsl:template match="ns0:expansion">
> <xsl:choose>
> <xsl:when test="@id">
> <ns0:expansion id="{@id}">
> <w:r><w:t> (<xsl:apply-templates/>)</w:t></w:r>
> </ns0:expansion>
> </xsl:when>
> <xsl:otherwise>
> <ns0:expansion>
> <w:r><w:t> (<xsl:apply-templates/>)</w:t></w:r>
> </ns0:expansion>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> -----------------
> 
>  
> > No that has no bearing on the copying of the
> attribute nodes.
> > Show a (complete, small) sample input and
> template...
> > 
> > David
> > 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.