xsl-list
[Top] [All Lists]

Re: How to filter nodes on attribute values

2003-03-11 04:28:34

Thanks for the suggestion.
Though your solution is elegant and easy one, I ll like to work out with the
alternative that you have suggested as :
<xsl:template match="Annotation[(_at_)type = 'interesting']">
   <DIV style="background:Yellow">
   <font face="Arial" color="RED">
      <xsl:apply-imports/>
   </font>
   </DIV>
</xsl:template>

<xsl:template match="Annotation[(_at_)type = 'useless']">
   <DIV style='background:PINK'>
   <font face="Arial" color='RED'>
      <xsl:apply-imports/>
   </font>
   </DIV>
</xsl:template>
I do this way because, I have no control over the XML file and the program
doesnot know the structure of the XML file.
Only thing that the program knows is that there are elements in the XML
file(anywhere in the hierarchy) with name ANNOTATION and certain attributes.
Depending upon the attributes I have to render the visibilty of the elements
that are the children of the ANNOTATION element but also importing their
original styles from the original stylesheet that is used in the XML doc.

Thanks for the suggestions.
Ankit

XSLList a écrit :

<xsl:template match="Annotation[(_at_)type='boring']">

which will give you more granular control over formatting.

Jeff

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl='http://www.w3.org/1999/XSL/Transform' >
<xsl:output method="html"/>

<xsl:template match="/">
        <html>
                <style>
                        .interesting {color: red;}
                        .boring {color: green;}
                </style>
                <body>
                        <xsl:apply-templates/>
                </body>
        </html>
</xsl:template>

<xsl:template match="Annotation">
        <p class="{(_at_)type}">
                <br/>
                Author = <xsl:value-of select="book/author"/><br/>
                Title = <xsl:value-of select="book/title"/><br/>
        </p>
</xsl:template>

</xsl:stylesheet>

<?xml version="1.0"?>
<Annotations>
         <Annotation type="interesting">
            <book id="bk106">
              <author>Randall, Cynthia</author>
              <title>Lover Birds</title>
            </book>
        </Annotation>
        <Annotation type="boring">
           <book id="bk102">
              <author>Ralls, Kim</author>
              <title>Midnight Rain</title>
            </book>
        </Annotation>
        <Annotation type="indifferent">
           <book id="bk102">
              <author>Ledbetter, James</author>
                        <title>Starving to Death on $200 Million</title>
            </book>
        </Annotation>
</Annotations>

Hello,
I have another problem.

I wish to apply formatting on a set of nodes which have a certain value
in the attribute.
I mean -
<Annotation type="interesting">
   <book id="bk106">
     <author>Randall, Cynthia</author>
     <title>Lover Birds</title>
   </book>
</Annotation>
<Annotation type="boring">
  <book id="bk102">
     <author>Ralls, Kim</author>
     <title>Midnight Rain</title>
   </book>
</Annotation>
-------------------
So that I can show all nodes ANNOTATION with
type="interesting" with RED
colored font and
all nodes ANNOTAITON with type="boring" with GREEN colored font.
Could somebody please guide me how to do this.
I donot wish to use When or If because I have to use
apply-imports which
doesnot work with When and If.

Thanks in advance
Ankit

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

--
Groupe Raisonnement, Action et Acte de Langage
IRIT-UMR-E.N.S.E.E.I.H.T.
2 rue Charles Camichel,
Toulouse, France.
Tel: +33 (0)5.61.58.82.00 extn : 8534
Fax: +33 (0)5.61.58.83.06
E-mail: Ankit(_dot_)Jain(_at_)enseeiht(_dot_)fr
http://www.enseeiht.fr/lima/ia/



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



<Prev in Thread] Current Thread [Next in Thread>