Q: How to select different style sheets at run time?

Subject: Q: How to select different style sheets at run time?
From: "Schwartz, Todd" <todd.schwartz@xxxxxxxxx>
Date: Thu, 19 Aug 1999 10:18:18 -0700
Hi,

I am wondering if anyone knows of a standard way to change the style sheet
applied to an XML document at run time. For example, I have a single XML
photo album document (see below) that contains both the thumbnail and
full-size versions of each photo. I have a default style sheet "album.xsl"
that displays a table with the thumbnails. What I would like is to somehow
make each thumbnail a link to the same XML document with a different style
sheet applied, say "photo.xsl". Microsoft has proprietary DOM extensions
that can do this; I was hoping there would be a more standard way. Seems
like there ought to be a way to specify "document + style sheet" in a URI...

Thanks, 
Todd 

  ------------------- 
  album.xml: 
  ------------------- 
  <?xml-stylesheet type='text/xsl' href='album.xsl'?> 
  <ALBUM> 
    <PHOTO> 
      <CAPTION>Photo 1</CAPTION> 
      <THUMBNAIL SRC="t_photo1.jpg" /> 
      <FULL_SIZE SRC="photo1.jpg" /> 
    </PHOTO> 
    <PHOTO> 
      <CAPTION>Photo 2</CAPTION> 
      <THUMBNAIL SRC="t_photo2.jpg" /> 
      <FULL_SIZE SRC="photo2.jpg" /> 
    </PHOTO> 
  </ALBUM> 


  -------------------------------- 
  album.xsl: 
  -------------------------------- 
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";> 

  <!-- This is the root document template --> 
  <xsl:template match="/"> 
  <HTML><BODY><CENTER> 
    <!-- Table of thumbnails goes here --> 
    <TABLE BORDER="1"> 
      <TR> 
        <xsl:for-each select="ALBUM/PHOTO"> 
          <TD ALIGN="CENTER"> 
            <A> 
              <!-- If the full-size image is not included, 
                   don't link to anything --> 
              <xsl:if test="FULL_SIZE"> 
                <xsl:attribute name="HREF"> 
                  <!-- Do something here that transforms album.xml 
                       with "photo.xsl" --> 
                </xsl:attribute> 
              </xsl:if> 
              <IMG> 
                <xsl:attribute name="SRC"> 
                  <xsl:value-of select="THUMBNAIL/@SRC"/> 
                </xsl:attribute> 
              </IMG> 
            </A> 
          </TD> 
        </xsl:for-each> 
      </TR> 
    </TABLE> 
  </CENTER></BODY></HTML> 
  </xsl:template> 

  </xsl:stylesheet> 


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


Current Thread