Subject: [xsl] Attribute values to string/text From: "Pankaj Chaturvedi" <pankaj.chaturvedi@xxxxxxxxx> Date: Wed, 9 Apr 2008 12:09:40 +0530 |
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."
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Ant xslt Approach Questio, Kamal Bhatt | Thread | Re: [xsl] Attribute values to strin, Jeff Sese |
[xsl] Ant xslt Approach Question, Z W | Date | Re: [xsl] Attribute values to strin, Jeff Sese |
Month |