xsl-list
[Top] [All Lists]

RE: Automatically copying an element's attributes and their values

2003-09-08 06:34:46
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="{(_at_)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="{(_at_)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



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