[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Writing conditional statement based on attribute

Subject: Re: Writing conditional statement based on attribute
From: llobash@xxxxxxxx
Date: Tue, 6 Feb 2007 10:08:36 -0500
Re:  Writing conditional statement based on attribute
sure, sorry, more complete example:

<dsc type="combined">

<c01
level="series"><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did>
<arrangement.</arrangement><scopecontent><p></p></scopecontent>

<c02
level="subseries"><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did>
<arrangement.</arrangement><scopecontent><p></p></scopecontent>

<c03
level="file"><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did>
<arrangement.</arrangement><scopecontent><p></p></scopecontent></c03>

<c03><did><unittitle><unitdate></unitdate></unittitle><physdesc></physdesc></did>
<arrangement.</arrangement><scopecontent><p></p></scopecontent></c03></c02></c01></dsc>

again, I am trying to format scopecontent one way where @level="series" or
"subseries" and another where @level="file" or there is no attribute level.

thanks again,
lynn



                                                                           
             Kamal Bhatt                                                   
             <kbhatt@xxxxxxxxx                                             
             >                                                          To 
                                       xsl-list@xxxxxxxxxxxxxxxxxxxxxx     
             02/05/2007 06:26                                           cc 
             PM                                                            
                                                                   Subject 
                                       Re:  Writing conditional       
             Please respond to         statement based on attribute        
             xsl-list@xxxxxxxx                                             
              lberrytech.com                                               
                                                                           
                                                                           
                                                                           
                                                                           




llobash@xxxxxxxx wrote:
> I am trying to write a conditional statement based on an attribute:
>
> The XML doc will have either @level=series, subseries, file, item, or no
> attribute.
>
> I would like the output to be in <p> with default font where
> @level="series" | @level="subseries"
>
> and  <font size="-1" color="gray"> where there is file, item or no level
> attribute. In other words anything but series or subseries.
>
> Here are two examples of XML:
>
> scopecontent is the element i am trying to format. parent element is dsc.
>
> <c01 level="series">
> <did>
> <container type="folder" label="Folder"> 15</container>
> <unittitle><unitdate>1932</unitdate></unittitle>
> </did>
> <scopecontent>
> <p> Includes letters regarding Lee Strasberg's health. </p>
> </scopecontent>
>
>
> <c04>
> <did>
> <container type="folder" label="Folder"> 15</container>
> <unittitle><unitdate>1932</unitdate></unittitle>
> </did>
> <scopecontent>
> <p> Includes letters regarding Lee Strasberg's health. </p>
> </scopecontent>
> </c04>
>
> I tried the following with no luck:
>
> <xsl:template match='dsc//scopecontent'>
> <xsl:choose>
>       <xsl:when test='* [@level="series"] |
>                   * [@level="subseries"]'>
>             <p>
>                   <xsl:apply-templates/>
>             </p>
>
>       </xsl:when>
>       <xsl:otherwise>
>             <font size="-1" color="gray">
>             <xsl:apply-templates/>
>             </font>
>       </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
>
You match is saying find all scopecontent elements in dsc. Your if
statement is wrong on two counts (I think). Firstly, I think the syntax
is wrong, I think you mean 'node()[@level="series"] or node [@level =
"subseries"]' but this is incorrect as you are searching for @level in
scopecontent. You should be looking in c01, c04, etc...
> Also:
>
> <xsl:template match='* [@level="series"]//scopecontent |
>              * [@level="subseries"]//scopecontent'>
>       <p>
>       <xsl:apply-templates/>
>       </p>
> </xsl:template>
>
> <xsl:template match='* [not (@level="series")]//scopecontent |
>              * [not (@level="subseries")]//scopecontent'>
>       <font size="-1" color="gray">
>       <xsl:apply-templates/>
>       </font>
> </xsl:template>
>
> Thanks for the help.
> Lynn
>
>
>
Can you give a more complete and correct example? From what you have
given us, you should not be matching on scopecontent first, but on c0x
where x is a number. We need to know more about these c0x elements. How
many are there, do they follow a pattern? are there any other sort of
elements in dsc? is there a b0x element?.

--
Kamal Bhatt

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.