Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old April 22nd, 2009, 06:42 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Microsoft are no longer working on a version 2.0 XSLT processor.
__________________
Joe
http://joe.fawcett.name/
Reply With Quote
  #12 (permalink)  
Old April 22nd, 2009, 08:03 AM
Authorized User
 
Join Date: Apr 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Input XML:

<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href="Sample.xsl" type="text/xsl"?>
<chapter version="5.1" xml:lang="en" xmlns="http://www.elsevier.com/xml/ehs-book/dtd" xmlns:sb="http://www.elsevier.com/xml/common/dtd" xmlns:ce="http://www.elsevier.com/xml/common/dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<cehttp://forums.tizag.com/images/smilies/tongue.gifii>
</cehttp://forums.tizag.com/images/smilies/tongue.gifii>
<ce:isbn>
</ce:isbn>
<ce:copyright type="full-transfer" year="2008">Elsevier Inc.</ce:copyright>
</info>
<ce:label/>
<ce:title/>
<ce:sections>
<cehttp://forums.tizag.com/images/smilies/tongue.gifara/>
</ce:sections>
<ce:bibliography id="biblio001">
<ce:section-title id="st0010">Vancouver style (Styles 3 (numbered) and 4 (name-date)):</ce:section-title>
<ce:bibliography-sec id="bibl001">
<ce:bib-reference id="bib001">
<ce:label>[1]</ce:label>
<sb:reference id="ref001">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Paivio</ce:surname>
<ce:given-name>A</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Jansen</ce:surname>
<ce:given-name>B</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Becker</ce:surname>
<ce:given-name>LJ</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Comparisons through the mind&apos;s eye</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Cognition</sb:maintitle>
</sb:title>
<sb:volume-nr>37</sb:volume-nr>
</sb:series>
<sb:issue-nr>2</sb:issue-nr>
<sb:date>1975</sb:date>
</sb:issue>
<sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
<sb:first-page>635</sb:first-page>
<sb:last-page>647</sb:last-page>
</sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
</sb:host>
</sb:reference>
</ce:bib-reference>
<ce:bib-reference id="bib002">
<ce:label>[2]</ce:label>
<sb:reference id="ref002">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Yuen</ce:surname>
<ce:given-name>AWC</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Lamotrigine: a review of antiepileptic efficacy</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Epilepsia</sb:maintitle>
</sb:title>
<sb:volume-nr>35</sb:volume-nr>
</sb:series>
<sb:issue-nr>Suppl. 5</sb:issue-nr>
<sb:date>1994</sb:date>
</sb:issue>
<sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
<sb:first-page>S33</sb:first-page>
<sb:last-page>S36</sb:last-page>
</sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
</sb:host>
</sb:reference>
</ce:bib-reference>
</ce:bibliography-sec>
</ce:bibliography>
</chapter>

my attempt XSL Document:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:sb="http://www.w3.org/1999/XSL/Transform" xmlns:ce="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xslhttp://forums.tizag.com/images/smilies/redface.gifutput use-character-maps="Allentities" method="xml"/>

<xsl:character-map name="Allentities">

<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&apos;" string="&apos;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x2013;" string="&amp;ndash;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00EB;" string="&amp;euml;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&lt;" string="&lt;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&gt;" string="&gt;"/>

<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x0023;" string="&amp;#x0023;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x0025;" string="&amp;#x0025;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x0026;" string="&amp;#x0026;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x0027;" string="&amp;#x0027;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00A0;" string="&amp;#x00A0;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00A9;" string="&amp;#x00A9;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00DF;" string="&amp;#x00DF;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00E4;" string="&amp;#x00E4;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00E8;" string="&amp;#x00E8;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00E9;" string="&amp;#x00E9;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00F6;" string="&amp;#x00F6;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00FC;" string="&amp;#x00FC;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x00FD;" string="&amp;#x00FD;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x010D;" string="&amp;#x010D;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x0161;" string="&amp;#x0161;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x2013;" string="&amp;#x2013;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x2018;" string="&amp;#x2018;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x2019;" string="&amp;#x2019;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x201C;" string="&amp;#x201C;"/>
<xslhttp://forums.tizag.com/images/smilies/redface.gifutput-character character="&#x201D;" string="&amp;#x201D;"/>
</xsl:character-map>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="ce:label[. = '[1]']">
<xsl:next-match/>
<xsl:text>,</xsl:text>
</xsl:template>

</xsl:stylesheet>

We need the Output XML Structure is below:

<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href="Sample.xsl" type="text/xsl"?>
<chapter version="5.1" xml:lang="en" xmlns="http://www.elsevier.com/xml/ehs-book/dtd" xmlns:sb="http://www.elsevier.com/xml/common/dtd" xmlns:ce="http://www.elsevier.com/xml/common/dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<cehttp://forums.tizag.com/images/smilies/tongue.gifii>
</cehttp://forums.tizag.com/images/smilies/tongue.gifii>
<ce:isbn>
</ce:isbn>
<ce:copyright type="full-transfer" year="2008">Elsevier Inc.</ce:copyright>
</info>
<ce:label/>
<ce:title/>
<ce:sections>
<cehttp://forums.tizag.com/images/smilies/tongue.gifara/>
</ce:sections>
<ce:bibliography id="biblio001">
<ce:section-title id="st0010">Vancouver style (Styles 3 (numbered) and 4 (name-date)):</ce:section-title>
<ce:bibliography-sec id="bibl001">
<ce:bib-reference id="bib001">
<ce:label>[1]</ce:label>,
<sb:reference id="ref001">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Paivio</ce:surname>
<ce:given-name>A</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Jansen</ce:surname>
<ce:given-name>B</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Becker</ce:surname>
<ce:given-name>LJ</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Comparisons through the mind&apos;s eye</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Cognition</sb:maintitle>
</sb:title>
<sb:volume-nr>37</sb:volume-nr>
</sb:series>
<sb:date>1975</sb:date>
<sb:issue-nr>2</sb:issue-nr>

</sb:issue>
<sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
<sb:first-page>635</sb:first-page>
<sb:last-page>647</sb:last-page>
</sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
</sb:host>
</sb:reference>
</ce:bib-reference>
<ce:bib-reference id="bib002">
<ce:label>[2]</ce:label>,
<sb:reference id="ref002">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Yuen</ce:surname>
<ce:given-name>AWC</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Lamotrigine: a review of antiepileptic efficacy</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Epilepsia</sb:maintitle>
</sb:title>
<sb:volume-nr>35</sb:volume-nr>
</sb:series>
<sb:date>1994</sb:date>
<sb:issue-nr>Suppl. 5</sb:issue-nr>

</sb:issue>
<sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
<sb:first-page>S33</sb:first-page>
<sb:last-page>S36</sb:last-page>
</sbhttp://forums.tizag.com/images/smilies/tongue.gifages>
</sb:host>
</sb:reference>
</ce:bib-reference>
</ce:bibliography-sec>
</ce:bibliography>
</chapter>

In the out xml need to swap the some elements i.e <sb:date>and <sb:issue-nr>, I will highlighted bold in the output format.

Insert some of the elements after commos, dot etc.... I show you the one sample is <ce:label> after the commos inserted in the output format.

Important:

In my xsl is able to copy all the element with attributes only, Not able to insert the commos in some of the elements, and swap also.

Please guide and help me if there is any different logic methods to achieve this task.

Thanks
Nagaraj
Reply With Quote
  #13 (permalink)  
Old April 22nd, 2009, 10:24 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Please wrap your XML and XSLT samples into code blocks to make them readable.
So use e.g.
Code:
[ code ]<root><foo>bar</foo></root>[ /code ]
(without the spaces between the square brackets and the word 'code') to display your code samples in a way that we can read them.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
  #14 (permalink)  
Old April 22nd, 2009, 10:44 AM
Authorized User
 
Join Date: Apr 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Input XML:

Code:
<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href="Sample.xsl" type="text/xsl"?>
<chapter version="5.1" xml:lang="en" xmlns="http://www.elsevier.com/xml/ehs-book/dtd" xmlns:sb="http://www.elsevier.com/xml/common/dtd" xmlns:ce="http://www.elsevier.com/xml/common/dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<ce:pii>
</ce:pii>
<ce:isbn>
</ce:isbn>
<ce:copyright type="full-transfer" year="2008">Elsevier Inc.</ce:copyright>
</info>
<ce:label/>
<ce:title/>
<ce:sections>
<ce:para></ce:para>
</ce:sections>
<ce:bibliography id="biblio001">
<ce:section-title id="st0010">Vancouver style (Styles 3 (numbered) and 4 (name-date)):</ce:section-title>
<ce:bibliography-sec id="bibl001">
<ce:bib-reference id="bib001">
<ce:label>[1]</ce:label>
<sb:reference id="ref001">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Paivio</ce:surname>
<ce:given-name>A</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Jansen</ce:surname>
<ce:given-name>B</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Becker</ce:surname>
<ce:given-name>LJ</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Comparisons through the mind&apos;s eye</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Cognition</sb:maintitle>
</sb:title>
<sb:volume-nr>37</sb:volume-nr>
</sb:series>
<sb:issue-nr>2</sb:issue-nr>
<sb:date>1975</sb:date>
</sb:issue>
<sb:pages>
<sb:first-page>635</sb:first-page>
<sb:last-page>647</sb:last-page>
</sb:pages>
</sb:host>
</sb:reference>
</ce:bib-reference>
<ce:bib-reference id="bib002">
<ce:label>[2]</ce:label>
<sb:reference id="ref002">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Yuen</ce:surname>
<ce:given-name>AWC</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Lamotrigine: a review of antiepileptic efficacy</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Epilepsia</sb:maintitle>
</sb:title>
<sb:volume-nr>35</sb:volume-nr>
</sb:series>
<sb:issue-nr>Suppl. 5</sb:issue-nr>
<sb:date>1994</sb:date>
</sb:issue>
<sb:pages>
<sb:first-page>S33</sb:first-page>
<sb:last-page>S36</sb:last-page>
</sb:pages>
</sb:host>
</sb:reference>
</ce:bib-reference>
</ce:bibliography-sec>
</ce:bibliography>
</chapter>
my attempt XSL Document:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:sb="http://www.w3.org/1999/XSL/Transform" xmlns:ce="http://www.w3.org/1999/XSL/Transform" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:output use-character-maps="Allentities" method="xml"/>

<xsl:character-map name="Allentities">

<xsl:output-character character="&apos;" string="&apos;"/>
<xsl:output-character character="&#x2013;" string="&amp;ndash;"/>
<xsl:output-character character="&#x00EB;" string="&amp;euml;"/>
<xsl:output-character character="&lt;" string="&lt;"/>
<xsl:output-character character="&gt;" string="&gt;"/>

<xsl:output-character character="&#x0023;" string="&amp;#x0023;"/>
<xsl:output-character character="&#x0025;" string="&amp;#x0025;"/>
<xsl:output-character character="&#x0026;" string="&amp;#x0026;"/>
<xsl:output-character character="&#x0027;" string="&amp;#x0027;"/>
<xsl:output-character character="&#x00A0;" string="&amp;#x00A0;"/>
<xsl:output-character character="&#x00A9;" string="&amp;#x00A9;"/>
<xsl:output-character character="&#x00DF;" string="&amp;#x00DF;"/>
<xsl:output-character character="&#x00E4;" string="&amp;#x00E4;"/>
<xsl:output-character character="&#x00E8;" string="&amp;#x00E8;"/>
<xsl:output-character character="&#x00E9;" string="&amp;#x00E9;"/>
<xsl:output-character character="&#x00F6;" string="&amp;#x00F6;"/>
<xsl:output-character character="&#x00FC;" string="&amp;#x00FC;"/>
<xsl:output-character character="&#x00FD;" string="&amp;#x00FD;"/>
<xsl:output-character character="&#x010D;" string="&amp;#x010D;"/>
<xsl:output-character character="&#x0161;" string="&amp;#x0161;"/>
<xsl:output-character character="&#x2013;" string="&amp;#x2013;"/>
<xsl:output-character character="&#x2018;" string="&amp;#x2018;"/>
<xsl:output-character character="&#x2019;" string="&amp;#x2019;"/>
<xsl:output-character character="&#x201C;" string="&amp;#x201C;"/>
<xsl:output-character character="&#x201D;" string="&amp;#x201D;"/>
</xsl:character-map>

<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>

<xsl:template match="ce:label[. = '[1]']">
<xsl:next-match/>
<xsl:text>,</xsl:text>
</xsl:template>

</xsl:stylesheet>
We need the Output XML Structure is below:

Code:
<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href="Sample.xsl" type="text/xsl"?>
<chapter version="5.1" xml:lang="en" xmlns="http://www.elsevier.com/xml/ehs-book/dtd" xmlns:sb="http://www.elsevier.com/xml/common/dtd" xmlns:ce="http://www.elsevier.com/xml/common/dtd" xmlns:xlink="http://www.w3.org/1999/xlink">
<info>
<ce:pii>
</ce:pii>
<ce:isbn>
</ce:isbn>
<ce:copyright type="full-transfer" year="2008">Elsevier Inc.</ce:copyright>
</info>
<ce:label/>
<ce:title/>
<ce:sections>
<ce:para></ce:para>
</ce:sections>
<ce:bibliography id="biblio001">
<ce:section-title id="st0010">Vancouver style (Styles 3 (numbered) and 4 (name-date)):</ce:section-title>
<ce:bibliography-sec id="bibl001">
<ce:bib-reference id="bib001">
<ce:label>[1]</ce:label>,
<sb:reference id="ref001">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Paivio</ce:surname>
<ce:given-name>A</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Jansen</ce:surname>
<ce:given-name>B</ce:given-name>
</sb:author>
<sb:author>
<ce:surname>Becker</ce:surname>
<ce:given-name>LJ</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Comparisons through the mind&apos;s eye</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Cognition</sb:maintitle>
</sb:title>
<sb:volume-nr>37</sb:volume-nr>
</sb:series>
<sb:date>1975</sb:date>
<sb:issue-nr>2</sb:issue-nr>
</sb:issue>
<sb:pages>
<sb:first-page>635</sb:first-page>
<sb:last-page>647</sb:last-page>
</sb:pages>
</sb:host>
</sb:reference>
</ce:bib-reference>
<ce:bib-reference id="bib002">
<ce:label>[2]</ce:label>,
<sb:reference id="ref002">
<sb:contribution>
<sb:authors>
<sb:author>
<ce:surname>Yuen</ce:surname>
<ce:given-name>AWC</ce:given-name>
</sb:author>
</sb:authors>
<sb:title>
<sb:maintitle>Lamotrigine: a review of antiepileptic efficacy</sb:maintitle>
</sb:title>
</sb:contribution>
<sb:host>
<sb:issue>
<sb:series>
<sb:title>
<sb:maintitle>Epilepsia</sb:maintitle>
</sb:title>
<sb:volume-nr>35</sb:volume-nr>
</sb:series>
<sb:date>1994</sb:date>
<sb:issue-nr>Suppl. 5</sb:issue-nr>
</sb:issue>
<sb:pages>
<sb:first-page>S33</sb:first-page>
<sb:last-page>S36</sb:last-page>
</sb:pages>
</sb:host>
</sb:reference>
</ce:bib-reference>
</ce:bibliography-sec>
</ce:bibliography>
</chapter>
In the out xml need to swap the some elements i.e <sb:date>and <sb:issue-nr>, I will highlighted bold in the output format.

Insert some of the elements after commos, dot etc.... I show you the one sample is <ce:label> after the commos inserted in the output format.

Important:

In my xsl is able to copy all the element with attributes only, Not able to insert the commos in some of the elements, and swap also.

Please guide and help me if there is any different logic methods to achieve this task.

I think it's ok for you!!!!!!!!!!
Reply With Quote
  #15 (permalink)  
Old April 22nd, 2009, 02:02 PM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Here is a sample XSLT 2.0 stylesheet that combines the earlier suggestion to add the comma with a template to swap the two elements:
Code:
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:ce="http://www.elsevier.com/xml/common/dtd"
  version="2.0">
  
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
  
  <xsl:template match="ce:label">
    <xsl:next-match/>
    <xsl:text>,</xsl:text>
  </xsl:template>
  
  <xsl:template match="ce:issue">
    <xsl:copy>
      <xsl:apply-templates select="@* | node() except (ce:issue-nr, ce:date)"/>
      <xsl:apply-templates select="ce:date, ce:issue-nr"/>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
  #16 (permalink)  
Old April 23rd, 2009, 05:55 AM
Authorized User
 
Join Date: Apr 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot!!!!!!!!!!

If the swap element <ce:issue-nr></ce:issue-nr><ce:date></ce:date> will be swapped to using your coding.

In the XML file input tag is <sb:date></sb:date><sb:issue-nr></sb:issue-nr> it doesn't swapped in the out xml, the style sheet as below,

Code:
<xsl:template match="sb:issue">
    <xsl:copy>
      <xsl:apply-templates select="@* | node() except (sb:issue-nr, sb:date)"/>
      <xsl:apply-templates select="sb:date, sb:issue-nr"/>
    </xsl:copy>
  </xsl:template>
Please help me how to proceed further.

Clear my doubts:

In these xml file having the two namespace prefix as ce: and sb:. We able to access only ce: namespace prefix in the xsl stylesheet. Any possibility to access the sb: namespace prefix elements using xslt.

Last edited by Nagaraj; April 23rd, 2009 at 06:15 AM.. Reason: Missing to add more notes
Reply With Quote
  #17 (permalink)  
Old April 23rd, 2009, 07:19 AM
Authorized User
 
Join Date: Jul 2007
Location: , , .
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

thank you, it helped me very much..
__________________
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Dictionary / Business / Games / Business
Reply With Quote
  #18 (permalink)  
Old April 23rd, 2009, 07:28 AM
Friend of Wrox
Points: 6,676, Level: 34
Points: 6,676, Level: 34 Points: 6,676, Level: 34 Points: 6,676, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2007
Location: Germany
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

You need to learn that it is not prefixes that matter but namespaces URIs. And while your input XML uses different namespaces like 'sb' and 'ce' those two prefixes are bound to the same namespace URI
xmlns:sb="http://www.elsevier.com/xml/common/dtd" xmlns:ce="http://www.elsevier.com/xml/common/dtd"
and that way, for the stylesheet it suffices to use one prefix bound to that namespace URI. The stylesheet is fine in my view so at least try it before posting "doubts". For the input you provided earlier it should work fine.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
Reply With Quote
  #19 (permalink)  
Old April 23rd, 2009, 07:51 AM
Authorized User
 
Join Date: Apr 2009
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks a lot Martin,

I really happy to come this forums... I like to learn about xslt full features, You have any references documents or any sites. Help me pleaseee.......
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add an attribute to each element bartnowa XSLT 3 November 8th, 2007 12:12 PM
How to add attribute to unbounded element 2BOrNot2B XML 4 January 16th, 2007 03:42 PM
javascript - add element to existing xml? willgotoo XML 4 October 8th, 2004 09:33 AM
How to Add a new element to Dataset after build Namita Crystal Reports 3 October 4th, 2004 01:13 AM
Add Mask To Input Element ritag HTML Code Clinic 4 July 20th, 2004 03:33 PM



All times are GMT -4. The time now is 01:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.