Re: [xsl] XSl Import and double styles

Subject: Re: [xsl] XSl Import and double styles
From: Ankit Jain <Ankit.Jain@xxxxxxxxxxx>
Date: Mon, 10 Mar 2003 15:52:36 +0100
Thanks for the help. But I really donot understand why this happens and how
to solve it. I have the following code copied from MSDN.

Books.xml
<?xml:stylesheet type="text/xsl" href="MSSample.xsl"?>
<catalog>
 <Annotation title="Testing Annotation" type="Interesting" author="jain"
comments="Another ONe" linkto="">
  <book id="bk102">
   <author>Ralls, Kim</author>
   <title>Midnight Rain</title>
   <genre>Fantasy</genre>
   <price>5.95<price1>5.95</price1></price>
   <Annotation title="whatsover" type="Important" author="jain"
comments="Good for me" linkto="">
    <publish_date>2000-12-16</publish_date>
   </Annotation>
   <description>A former architect battles corporate zombies,
         an evil sorceress, and her own childhood to become queen
         of the world.
         </description>
  </book>
 </Annotation>


 <book id="bk106">
  <Annotation type="interesting">
   <author>Randall, Cynthia</author>
  </Annotation>
  <title>Lover Birds</title>
  <genre>Romance</genre>
  <price>4.95</price>
  <publish_date>2000-09-02</publish_date>
  <description>When Carla meets Paul at an ornithology
      conference, tempers fly as feathers get ruffled.</description>
 </book>

</catalog>
------------------------
MSSample-import.xsl --->
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">

<!-- Override built-in template. -->
<xsl:template match="text()"/>

<xsl:template match="/">
  <html>
    <body>
      <xsl:apply-templates/>
    </body>
  </html>
</xsl:template>

<xsl:template match="book">
  <i>
    <xsl:apply-templates select="title"/>
  </i>
    <xsl:text> By: </xsl:text>
  <xsl:apply-templates select="author"/>
  <br/>
</xsl:template>

<xsl:template match="title">

  <b>
    <xsl:value-of select="."/>
  </b>

</xsl:template>

<xsl:template match="author">
  <font color="blue">
    <xsl:value-of select="."/>
  </font>
</xsl:template>

</xsl:stylesheet>
--------------------
MSSample.xsl --->
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="1.0">
<xsl:import href="MSsample-import.xsl"/>
<xsl:output method="html"/>

<xsl:template match="Annotation">
   <DIV style="background:Yellow">
   <font face="Arial" color="RED">
      <xsl:apply-imports/>
   </font>
   </DIV>
</xsl:template>

</xsl:stylesheet>
-----------------------

Now while displaying the file, only if the Annotation tag is the parent of
the book tag, then only the contents are displayed . Else if, the annotation
tag is made parent of (say.. <author> tag), then the contents of the tag
disappear; Why ?

Also, the font color of the font is not overrided to RED as per the
priority.. It is still shown as Blue for the author.

THanks and Regards
ANkit



Michael Kay a écrit :

> This is exactly what xsl:apply-imports does.
>
> Michael Kay
> Software AG
> home: Michael.H.Kay@xxxxxxxxxxxx
> work: Michael.Kay@xxxxxxxxxxxxxx


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


Current Thread