W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2004

Re: copy elements with all attributes...

From: G. Ken Holman <gkholman@CraneSoftwrights.com>
Date: Mon, 12 Jan 2004 19:22:14 -0500
Message-Id: <>
To: <xmlschema-dev@w3.org>

At 2004-01-13 00:17 +0100, Nikolas Nehmer wrote:
>I have an XML file with a XSL stylesheet whick looks like this:
><?xml version="1.0" encoding="UTF-8"?>
><?xml-stylesheet type="text/xsl" href="person.xsl"?>
><iese:person xmlns:iese="http://www.iese.fhg.de" 
>        <iese:firstname>Nikolas</iese:firstname>
>        <iese:lastname>Nehmer</iese:lastname>
>        <iese:author_of xlink:type="simple" xlink:show="new" 
> xlink:href="publication.xml"/>
>Now I want my XSL rules process the following output:
><iese:author_of xlink:type="simple" xlink:show="replace" 
>xlink:href="publication.xml">Some Text</iese:author_of>
>How do I achieve this?

You can use xsl:copy-of for all of the attributes and then override the 
xlink:show attribute using an <xsl:attribute> instruction.

>Do I have to use the xsl:copy

Yes, for the element ... and xsl:copy-of for the old attributes.

>and use-attribute-sets?


>Or is it possible to inherit the whole element with all its attributes and 
>attribute values.

"Inherit"?  No such semantic is in XSLT ... you can construct in the result 
tree a copy of the node that is the current node:

<xsl:template match="iese:author_of">
     <xsl:copy-of select="@*"/>
     <xsl:attribute name="xlink:show">replace</xsl:attribute>
     <xsl:text>Some Text</xsl:text>

You can redefine the content of an attribute any number of times before 
beginning a result element's content ... the last one sticks.

>I would be very happy about some help.

You are asking at the wrong list ...

XSLT and XPath questions would be better posted to the following list:


There are a number of subscribers who would enthusiastically respond to 
such questions.

There is also an *excellent* FAQ at:


I hope this helps.

........................ Ken

p.s. I note your email domain is in Germany ... I hope to soon announce 
XSLT and XSL-FO training courses in the north of Germany (Bremen? Hamburg? 
Hannover?) ... please check our web site for details.

North America (Washington, DC): 3-day XSLT/2-day XSL-FO 2004-03-15
Instructor-led on-site corporate, government & user group training
for XSLT and XSL-FO world-wide:  please contact us for the details

G. Ken Holman                 mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/x/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
ISBN 0-13-065196-6                       Definitive XSLT and XPath
ISBN 0-13-140374-5                               Definitive XSL-FO
ISBN 1-894049-08-X   Practical Transformation Using XSLT and XPath
ISBN 1-894049-11-X               Practical Formatting Using XSL-FO
Member of the XML Guild of Practitioners:     http://XMLGuild.info
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/x/bc
Received on Monday, 12 January 2004 19:25:42 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:04 UTC