Subject: Re: [xsl] Attribute values to string/text From: Jeff Sese <jeferson.sese@xxxxxxxxxxxx> Date: Wed, 9 Apr 2008 15:35:57 +0800 |
<xsl:template match="*[@dummy]"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:value-of select="@dummy"/> </xsl:copy> </xsl:template> <xsl:template match="@dummy"/> <!-- to remove the dummy attribute -->
<xsl:template match="meta"> <xsl:copy> <xsl:apply-templates select="/article/journalcode|/articel/issn"/> </xsl:copy> </xsl:template>
Hello all,
I am trying to convert all the "dummy" attribute name to its corresponding
element text in a generic way. Secondly I also need to define elements
<journalcode>, and both <issn> to be appear as child element of <meta>
(though I've not tested it yet). Below is what I've tried to do but I am
able to pick the value of @dummy resulting into <issn type="print"></issn>
and so on.
Can somebody shed some light on it, where I am being wrong.
XML ===== <article> <meta/> <journalcode dummy="CIJB"/> <issn type="print" dummy="0269-2171"/> <issn type="electronic" dummy="1465-3486"/> </article>
Desired Output ============
<article> <meta> <journalcode>CIJB</journalcode> <issn type="print">0269-2171</issn> <issn type="electronic">1465-3486</issn> </meta> </article>
Stysheet ========
<xsl:template match="*|@*"> <xsl:choose> <xsl:when test="name()='dummy'"> <xsl:copy-of select="@*"/> <xsl:value-of select="string(./@dummy)"/> </xsl:when> <xsl:otherwise> <xsl:copy> <xsl:apply-templates select="text()|*|@*"/> </xsl:copy> </xsl:otherwise> </xsl:choose> </xsl:template>
Best,
Pankaj Chaturvedi
====================================================================== ======
================
Confidentiality Notice:" This message and any attachment(s) contained here are information that is confidential, proprietary to IDS Infotech Ltd. and its customers. Contents may be privileged or otherwise protected by law. The information is solely intended for the individual or the entity it is addressed to. If you are not the intended recipient of this message, you are not authorized to read, forward, print, retain, copy or disseminate this message or any part of it. If you have received this e-mail in error, please notify the sender immediately by return e-mail and delete it from your computer."
Jeferson L. Sese jeferson dot sese at asiatype dot com Asiatype Incorporated Suite 114 Columbia Tower, Ortigas Ave. Greenhills, Mandaluyong City 1550 Philippines
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Attribute values to string/te, Pankaj Chaturvedi | Thread | RE: [xsl] Attribute values to strin, Pankaj Chaturvedi |
[xsl] Attribute values to string/te, Pankaj Chaturvedi | Date | RE: [xsl] Attribute values to strin, Pankaj Chaturvedi |
Month |