|
Subject: Re: [xsl] moving an element and then converting it to an attribute From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Wed, 15 Aug 2012 15:47:11 -0400 |
Hi, I'm pretty new to XSLT and I'm having some trouble with a project.
I have the following XML:
<media.block id="fun1"> <caption> <para> <txt> <image-size> spread </image-size> </txt> </para> </caption> <media filename="1234567"/> </media.block>
What I want is to turn the image-size node into an attribute of the media element, so it looks like this:
<media.block id="fun1"> <caption> <para> <txt> <image-size> spread </image-size> </txt> </para> </caption> <media filename="0801_75750-rm" image-size="spread"/> </media.block>
But I keep getting stuck. I was thinking I might need to move the image-size node somewhere before I could turn it into an attribute of the media element? Can anyone help me with this? I'm just using version 1, not 2.
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*/>
</xsl:copy>
</xsl:template><xsl:template match="image-size" mode="size-attribute">
<!-- making an attribute -->
<xsl:attribute name="image-size">
<!-- trimming extra white space from the value -->
<xsl:value-of select="normalize-space()"/>
</xsl:attribute>
</xsl:template>I hope this helps, Wendell
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] moving an element and the, G. Ken Holman | Thread | Re: [xsl] moving an element and the, Michael Müller-Hille |
| Re: [xsl] moving an element and the, G. Ken Holman | Date | [xsl] Running out of Memory, Terry Badger |
| Month |