xsl-list
[Top] [All Lists]

[xsl] Moving an element along with data manipulation

2008-04-08 02:09:25
Hi,

I am trying move an xml element (along with its corresponding child
elements) in my final output (<author> here to move below <title> along with
extra punctuation generated thru stylesheet with in its child element).
Below is my sample xml input, desired output and stylesheet defined by me.

Problem: Author element is moving after <title> with desired punctuation but
it is also appearing in <meta> element with same info. If I simply try to
move <author>s with no data manipulation (no punctuation), its quite easy,
but all I need it to remove it from <meta> and place it after <title>.

Can somebody suggest where I am wrong?


XML Input:
========

<?xml version="1.0" encoding="UTF-8"?>
<article>
<meta>
<abc>xxxxxxxxx</abc>
<author>
<name><givenname>Mohsen</givenname><surname>Bahmani&hyphen;Oskooee</surname>
</name>
</author>
<author>
<name><givenname>Gour</givenname><inits>G.</inits><surname>Goswami</surname>
</name>
</author>
<author>
<name><givenname>Bidyut</givenname><middlename>Kumar</middlename><surname>Ta
lukdar</surname></name>
</author>
</meta>
<journaltitle>International Review of Applied Economics</journaltitle>
<title><newpage pagenumber="93"/>The bilateral J&hyphen;curve: Canada versus
her 20 trading partners</title>
</article>



Output
=====


<?xml version="1.0" encoding="UTF-8"?>
<article>
<meta>
<abc>xxxxxxxxx</abc>
</meta>
<journaltitle>International Review of Applied Economics</journaltitle>
<title title_tt="art_title"><newpage pagenumber="93"/>The bilateral
J&#x02010;curve: Canada versus her 20 trading partners</title><char>
</char>
<author au_st="au"><name><givenname>Mohsen</givenname><char>
</char><surname>Bahmani&#x02010;Oskooee</surname></name></author><char>,
</char><author au_st="au"><name><givenname>Gour</givenname><char>
</char><surname>Goswami</surname></name></author><char> and </char><author
au_st="au"><name><givenname>Bidyut</givenname><char>
</char><surname>Talukdar</surname></name></author>
</article>


Stylesheet
========


<xsl:template match="author">
<xsl:copy>
<xsl:attribute name="au_st">au</xsl:attribute>
<xsl:copy-of select="@*"/>
<xsl:element name="name">
<xsl:apply-templates select=".//givenname"/>
<char><xsl:text> </xsl:text></char>
<xsl:apply-templates select=".//surname"/>
</xsl:element>
</xsl:copy>
<xsl:choose>
<xsl:when test="count(following-sibling::author)=1 and count(//author)!=1">
<char><xsl:text> and </xsl:text></char>
</xsl:when>
<xsl:when test="count(following-sibling::author)=0">
</xsl:when>
<xsl:otherwise>
<char><xsl:text>, </xsl:text></char>
</xsl:otherwise>
</xsl:choose>
</xsl:template>



<xsl:template match="article/title">
<char><xsl:text>&#x0000A;</xsl:text></char>
        <xsl:element name="title">
                <xsl:attribute name="title_att">art_title</xsl:attribute>
                <xsl:copy-of select="@*"/>
                <xsl:apply-templates/>
                </xsl:element>
                        <char><xsl:text>&#x0000A;</xsl:text></char>
<xsl:copy>
        <xsl:apply-templates select="preceding-sibling::meta/author"/>
</xsl:copy>
        </xsl:template>







Best,

Pankaj Chaturvedi

============================================================================
================

<HTML><BODY><P><hr size=1></P>
<P><STRONG>

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."

</STRONG></P></BODY></HTML>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--