TLE>RE: Newbie question - dynamic filter on attribute values -htdig_noindex-->

This is the mail archive of the xsl-list@mulberrytech.com mailing list .


>
Index Nav: [Date Index] [Subject Inda>] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Thread ]

REwbie question - dynamic filter on attribute values


If you can get the HjÂ: oattribute nu$wanted, then you're home and dry: you can write logic like <est="@attr=$wanted"> or <for-each select="chap[@attr=$wanted]"> which tests
whether the @attr attribute is equal to one of the nodes in $wanted.

So how to establish the node-set? The only standard way to do it is to
create a secondary XMLument containing the required numbers, and read it
using the document() function. There was a similar solution posted earlieday. Or you could use various non-standard facilities, for example you
could pass in a space-separated list of numbers and tit into a node-set
using Saxon's new tokenize() extension function.

Mike Kay

> -----Original Message-----
> From: Su Karen [mailto:Karen.Super@westgroup.com]
> Sent: 16 February 2000 17:59
 To: 'XSL-List@mulberrytech.com'
> Subject: Newbie question - dynamic filter on attribute values
> 
> 
> I apolo if this has already been discussed, but I am new 
> to XML and XSLT
> and have been reading some of the posts and hav seem to 
> come across my
> situation.  I have data similar to the following:
> 
> <book attr="1">
>  lt;title attr="10">This is the title</title>
>     <chap attr="20">
>         <title attr="25">Chr title 1</title>
>         <para attr="26">This is a paragraph in the first 
> chapter</para>
> </chap>        
>     <chap attr="20">
>         <title attr="25">Chapter title 2</title>
>     <para attr="26">This is a paragraph in the second 
> chapter</para>
>     </chap>        
> /book>
> 
> I would like to initially filter out my document based on the 
> attr values.
> I will be receivin array of numbers that correspond to 
> the numbers in
> attr.  I only want those elements that match these numbers. t; For example, if
> I receive 25 and 26, I only want to work with the <title> and <para>
> elements.  Thiray of numbers that I will be receiving 
> will vary from
> request to request, meaning I may get a request for only 1gt; and 25, or just
> 26.  I would like to somehow dynamically combine this logic into the
> following stylesheet, butm not sure how to do it.
> 
> <xsl:template match="chap/title">
>     <FormatScope>
> 	 <Format&ggt; 	     <ESC/>TB
> 		 </Format>
> 		 <Content>
> 		     <xsl:apply-templates/>
> 		 &lontent>
> 		 <Format>
> 		     <ESC/>TE
> 		 </Format>
>     </FormatScope>
> <:template>
> 
> <xsl:template match="para">
>     <FormatScope>
>         <Format>
>    HjÂ:   <ESC/>  <Content>
>             <xsl:apply-templates/>
         </Content>
>         <Format>
>             <ESC/>PE
>         </Format>
>     /FormatScope>
> </xsl:template>
>   
> The resulting XML would be:
> 
> <FormatScope>
>    ;Format>
>         <ESC/>TB
>     </Format>
>     <Content>Chapter title 1</Content>
>  <Format>
>         <ESC/>TE
>     </Format>
> </FormatScope>
> 
> <FormatScope&ggt;     <Format>
>         <ESC/>PB
>     </Format>
>     <Content>This is a paragraph in tirst chapter</Content>
>     <Format>
>         <ESC/>PE
>     </Format>
> </FormatScgt;
> 
> <FormatScope>
>     <Format>
>         <ESC/>TB
>     </Format>
>     <tent>Chapter title 2</Content>
>     <Format>
>         <ESC/>TE
>     </Format>
> &lormatScope>
> 
> <FormatScope>
>     <Format>
>         <ESC/>PB
>     </Format>
&    <Content>This is a paragraph in the second chapter</Content>
>     <Format>
>         <ESC/&g
>     </Format>
> </FormatScope>
> 
> 
> Using XSLT, is there a way to do what I am trying to aclish?  Any
> suggestions are greatly appreciated.
> 
> Thanks,
> Karen
> 
> 
>  XSL-List info and archiHjÂ: < HREF="http:www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info andhive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: HREF="index.html#00478">Date Index] [Subject Index] [Author Index] [Thread Index]
Mee Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
-/htdig_noindex-->