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: <5.2.0.9.0.20040112191341.00bda0e8@pop.storm.ca>
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" 
>xmlns:xlink="http://www.w3.org/1999/xlink" 
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
>xsi:schemaLocation="http://www.iese.fhg.de 
>C:\projects\person_and_publication_xlink\person.xsd">
>        <iese:firstname>Nikolas</iese:firstname>
>        <iese:lastname>Nehmer</iese:lastname>
>        <iese:author_of xlink:type="simple" xlink:show="new" 
> xlink:href="publication.xml"/>
></iese:person>
>
>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?

No.

>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>
     <xsl:copy-of select="@*"/>
     <xsl:attribute name="xlink:show">replace</xsl:attribute>
     <xsl:text>Some Text</xsl:text>
   </xsl:copy>
</xsl:template>

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:

   http://www.mulberrytech.com/xsl/xsl-list

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

There is also an *excellent* FAQ at:

   http://www.dpawson.co.uk

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:41 GMT