Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 24th, 2006, 01:56 PM
Authorized User
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT problem

I wrote a xslt for converting xml to html. I have small problem regarding formats.I need to display the references as Ordered List Items in HTML.

Here is the small part of the main xml:


<ref-list>
    <title>References</title>
    <ref id="R1">
        <citation citation-type="web">
            <label>1</label>.#x0009;<collab>ABC</collab>. 2004 West Nile virus activity in the United States.
        </citation>
    </ref>
    <ref id="R2">
        <citation citation-type="web">
            <label>2</label>.#x0009;<collab>ABC</collab>. Addressing emerging infectious disease threats: a prevention strategy for the United States. Atlanta, GA: US Department of Health and Human Services
            </citation>
    </ref>
    <ref id="R3">
        <citation citation-type="web">
            <label>3</label>.#x0009;<collab>ABC</collab>. Preventing emerging infectious disease: a strategy for the 21st century. Atlanta, GA: US Department of Health and Human Services
           </citation>
    </ref>
</ref-list>


   How can i skip the parsing <label>1</label>.#x0009; in the above xml? I can skip the parsing label by using

   <xsl:template match="label"></xsl:template>, but i don't know how to skip .#x0009;. Can somebody help me?

 
Old March 24th, 2006, 02:50 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Try

<xsl:template match="text()[.='.#x0009;']"/>

However, if the data is messier than this and you need to test more complex conditions, you may need a different approach.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 24th, 2006, 03:34 PM
Authorized User
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much. it did work for me. since it is a large xml i did use like this.

    <xsl:template match="text()[.='.#x0009;']" priority="2"/>
    <xsl:template match="text()" priority="1">
                <xsl:copy-of select="."/>
    </xsl:template>

 Is there any way i can add condition .#x0009; comes after label elemnet?

Thanks once again,
pendyala.


Quote:
quote:Originally posted by mhkay
 Try

<xsl:template match="text()[.='.#x0009;']"/>

However, if the data is messier than this and you need to test more complex conditions, you may need a different approach.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 24th, 2006, 03:54 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Is there any way i can add condition .#x0009; comes after label elemnet?

<xsl:template match="text()[.='.#x0009;']
                     [preceding-sibling::node()[1][self::label]]"/>

Your rule

<xsl:template match="text()" priority="1">
                <xsl:copy-of select="."/>
    </xsl:template>

is quite unnecessary. It's what the default template does anyway.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old March 24th, 2006, 04:08 PM
Authorized User
 
Join Date: Mar 2006
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help. i did remove the unnecessary template. Everything is working fine.

pendyalap.


Quote:
quote:Originally posted by mhkay
 Is there any way i can add condition .#x0009; comes after label elemnet?

<xsl:template match="text()[.='.#x0009;']
                     [preceding-sibling::node()[1][self::label]]"/>

Your rule

<xsl:template match="text()" priority="1">
                <xsl:copy-of select="."/>
    </xsl:template>

is quite unnecessary. It's what the default template does anyway.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT problem with IE 7 asadallahi BOOK: Professional Ajax ISBN: 978-0-471-77778-6 3 April 9th, 2009 09:33 AM
xslt problem mickhughes XSLT 3 March 28th, 2008 05:09 AM
XSLT problem her_today XSLT 1 October 23rd, 2006 11:09 AM
dynamic xslt -> xslt creation namespace problem jkmyoung XSLT 2 July 15th, 2006 12:42 AM
problem with xslt superwebba BOOK: Professional Ajax ISBN: 978-0-471-77778-6 5 March 10th, 2006 01:31 AM





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