RE: [xsl] Converting attribute value to XML!

Subject: RE: [xsl] Converting attribute value to XML!
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 23 Jan 2004 12:12:55 -0500
At 2004-01-23 11:30 -0500, Amuchastegui, Maria wrote:
Try this. - Maria
...
<filed>
<xsl:attribute name="name"><xsl:value-of select="@name"/></xsl:attribute>

Maria, when using literal result elements, you can use an attribute value template to be more succinct:


<filed name="{@name}">

... or you can use the copy-of instruction:

  <filed>
    <xsl:copy-of select="@name"/>

... which is really handy when you want to copy all attributes:

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

... which you don't want in this particular example.

Remember that you are constructing the result tree and there are four ways of adding attribute nodes to the result tree,

 (1) - xsl:use-attribute-sets=
 (2) - attribute specifications in a literal result element
 (3) - <xsl:attribute>
 (4) - <xsl:copy-of>

For the attributes of any given element, the priority is (1), (2), (3 and 4 in stylesheet order). The result tree isn't completed for a given set of attributes until content is defined for the element in which the attributes are used. As soon as content is defined, the set of attribute nodes cannot be changed.

I hope this helps.

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


-- Public courses: sign up for one or both soon to reserve your seat! Each week: Monday-Wednesday: XSLT/XPath; Thursday-Friday: XSL-FO Washington, DC: 2004-03-15 San Francisco, CA: 2004-03-22 Hong Kong, China: 2004-05-17 Bremen, Germany: 2004-05-24 World-wide on-site corporate, government & user group XML training

G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Breast Cancer Awareness  http://www.CraneSoftwrights.com/s/bc


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



Current Thread