xsl-list
[Top] [All Lists]

RE: XPath question.

2003-05-06 21:02:34

At 03:43 PM 5/7/2003 +1200, Hemi Kara wrote:
<xsl:if test="starts-with(encyclopedia/entry/title, 'Q') or
starts-with(encyclopedia/entry/episode, 'Q')">

I tried that, too. I was incorrect in my previous reply to Rob Rohan -- if I put a 'not' in the expression, my text shows up.

I'm posting the entire stylesheet here for your further perusal. The XML document it applies to is available at: http://www.shastamedia.com/anomaly/encyclopedia.xml with an associated document fragment at http://www.shastamedia.com/anomaly/entries.xml.

        Any help is appreciated, because I'm stumped.

--->Ben

===========

<?xml version="1.0"?>
<!DOCTYPE xsl:transform [
<!ENTITY css SYSTEM "anomaly.css">
<!ENTITY nbsp "&#160;">
]>



<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<!--
This stylesheet takes a file based on encyclopedia.dtd, and shoots out the proper formatting for Anomaly MUSH's webpage.
Author: Ben Trafford (genesisweapon(_at_)yahoo(_dot_)com)
Date Created: 04.29.2003
Date Last Modified: 05.06.2003
-->

  <!-- $stylesheet-version is the version number of this stylesheet. -->
  <xsl:variable name='stylesheet-version' select="'1.0'" />
  <xsl:template match='encyclopedia'>
    <html>
      <head>
        <title>Anomaly TrekMUX</title>
                                <base target="_self"></base>
<link rel="stylesheet" href="anomaly.css" type="text/css"></link> <link rel="stylesheet" title="default stylesheet" media="screen" href="http://anomaly.mushpark.com/test/Styles/AnomalyDefault.css";></link>
                        </head>
      <body bgcolor="#000000">
<table border="0" width="686" cellspacing="0" cellpadding="0" height="20">
                                <tr>
<td width="38" align="right" valign="top" height="20"> <p align="right"><img border="0" src="http://anomaly.mushpark.com/images/lcars-smallbullet-l1.gif"; width="36" height="18"></img></p>
                                        </td>
<td width="701" align="left" valign="top" height="20"> <img border="0" src="http://anomaly.mushpark.com/images/lcars-shortbar-1.gif"; width="700" height="18"></img></td> <td width="43" height="20" valign="top" align="left"> <p align="center"><img border="0" src="http://anomaly.mushpark.com/images/lcars-smallbullet-r1.gif"; align="left" width="36" height="18"></img></p>
                                        </td>
                                </tr>
                                <tr>
<td width="38" align="right" valign="top" height="20">
                                                <p align="center"></p></td>
<td width="696" align="left" valign="top" height="20">
                                        <script language="javascript">
<!--
function popupsug(id1) {
popupWin = window.open(id1,'Suggest','width=650,height=600,status=yes,resizable=yes,scrollbars=yes')
}
-->
                                        </script>
                                        <br></br>
                                        <center>
                                                <table width="95%" border="0">
                                                        <tr>
                                                                <td>
<p align="center"> <a href="A.html">A</a>- <a href="B.html">B</a>- <a href="C.html">C</a>- <a href="D.html">D</a>- <a href="E.html">E</a>- <a href="F.html">F</a>- <a href="G.html">G</a>- <a href="H.html">H</a>- <a href="I.html">I</a>- <a href="J.html">J</a>- <a href="K.html">K</a>- <a href="L.html">L</a>- <a href="M.html">M</a>- <a href="N.html">N</a>- <a href="O.html">O</a>- <a href="P.html">P</a>- <a href="Q.html">Q</a>- <a href="R.html">R</a>- <a href="S.html">S</a>- <a href="T.html">T</a>- <a href="U.html">U</a>- <a href="V.html">V</a>- <a href="W.html">W</a>- <a href="X.html">X</a>- <a href="Y.html">Y</a>- <a href="Z.html">Z</a>
                                                                        </p>
<p align="center">Alphabetical Title Goes Here</p>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td>

<form method="post" action="encyclopedia/sort.cgi"> <div align="center"><font face="verdana" size="1">Search <select name="cat"> <option value="0">All</option> <option value='1'> Episodes</option> <option value='2'> Stars</option> <option value='3'> Guest Stars</option> <option value='4'> Species</option> <option value='5'> Ships</option> <option value='6'> Place</option> <option value='7'> Science</option> <option value='8'> Miscellaneous</option>
                                                                                      
  </select>
                                                                                      
  for:</font>
<input type="text" name="search" size="25"></input> <input type="submit" name="Go" style="font-size: 8pt; font-family: verdana; color: #FFFFFF; font-weight: bold; background-color: #000045" value="Go"></input>
                                                                                
</div>
                                                                        </form>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td>
<xsl:if test="starts-with(encyclopedia/entry/title, 'Q') or starts-with(encyclopedia/entry/episode, 'Q')">
                   <xsl:call-template name="no.entry.found"/>
                </xsl:if>

<!-- Apply the usual template if a title or episode matches Q, otherwise, don't -->

                                                <xsl:apply-templates>
<xsl:sort select="title|episode"/>
                                                </xsl:apply-templates>
                                                                </td>
                                                        </tr>
                                                </table>
                                        </center>
                                </td>
                                </tr>
                                </table>
<table border="0" width="734" cellspacing="0" cellpadding="0" height="20">
                                          <tr>
<td width="36" align="right" valign="top" height="20"> <p align="right"><img border="0" src="images/lcars-bullet-l2.gif" width="36" height="36"></img></p>
                                            </td>
<td width="701" align="left" valign="top" height="20"> <img border="0" src="http://anomaly.mushpark.com/images/lcars-bottom-2.gif"; width="700" height="36"></img></td> <td width="44" height="20" valign="top" align="left"> <p align="center"><img border="0" src="images/lcars-bullet-r1.gif" align="left" width="36" height="36"></img></p>
                                            </td>
                                          </tr>
                                </table>
              </body>
    </html>
  </xsl:template>

        <xsl:template name="no.entry.found">
                <br></br><br></br>
<table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
                                <tr>
                                        <td>
                                                <!-- temporary test code -->


<p align="center"><font face="verdana" size="2"> There are no items at present, please check back again soon.</font>
                                                </p>
                                                <br></br><br></br>
                                                <p align="center">
                                                        <hr width="75"></hr>
                                                </p>
                                        </td>
                                </tr>
                        </table>
        </xsl:template>

        <xsl:template match="entry">
<xsl:if test="starts-with(title, 'Q') or starts-with(episode, 'Q')"> <table width="95%" cellspacing="0" cellpadding="0" border="0" align="center">
                <xsl:apply-templates/>
                                </table>
                                <br></br><br></br><br></br>
      </xsl:if>
        </xsl:template>

        <xsl:template match="episode">
                <tr bgcolor="#FF9900">
        <td align="left" colspan="2" height="20">
                        <font face="verdana" size="2" color="black">
                                <strong>
                                                <xsl:apply-templates/>
                                        </strong> &nbsp; &nbsp;
                                </font>
                                <a name="{../@id}"></a>
                        </td>
                </tr>
        </xsl:template>

        <xsl:template match="title">
                <tr bgcolor="#FF9900">
        <td align="left" colspan="2" height="20">
                        <font face="verdana" size="2" color="black">
                                <strong>
                                                <xsl:apply-templates/>
                                        </strong> &nbsp; &nbsp;
                                </font>
                        <a name="{../@id}"></a>
                        </td>
                </tr>
        </xsl:template>

        <xsl:template match="body">
                <tr>
                        <td align="left" colspan="2">
                                <font face="verdana" size="2">
                                        <xsl:apply-templates/>
                                </font>
                        </td>
                </tr>
        </xsl:template>

        <xsl:template match="paragraph">
                <p>
                        <font face="verdana" size="2">
                                <xsl:apply-templates>
                                </xsl:apply-templates>
                        </font>
                </p>
        </xsl:template>

        <xsl:template match="entry.links">
                                <b>SEE ALSO:
                                <xsl:apply-templates>
                                        <xsl:sort select="@to.entry"/>
                                </xsl:apply-templates>.</b>
        </xsl:template>

        <xsl:template match="entry.link">
<i><a href="#{(_at_)to(_dot_)entry}"><xsl:apply-templates/></a> <xsl:if test="not(position()=last())">; </xsl:if>
                                                </i>
  </xsl:template>

        <xsl:template match="standalone.entry.link">
<b>SEE ALSO: <i><a href="#{(_at_)to(_dot_)entry}"><xsl:apply-templates/></a>. </i></b>
        </xsl:template>


        <xsl:template match="episode.link">
<i>(<a class="episode.link" href="#{(_at_)to(_dot_)episode}"><xsl:apply-templates/></a>) </i>
        </xsl:template>

  <xsl:template match="img">
        <xsl:if test="not(@alt.text)">
                        <xsl:choose>
                                <xsl:when test="@width">
<img src="{(_at_)src}" alt="{../../../title}" border="0" align="{(_at_)align}" width="{(_at_)width}"></img>
                        </xsl:when>
                                <xsl:otherwise>
<img src="{(_at_)src}" alt="{../../../title}" border="0" align="{(_at_)align}"></img>
                        </xsl:otherwise>
                  </xsl:choose>
        </xsl:if>
        <xsl:if test="@alt.text">
                                <xsl:choose>
                                <xsl:when test="@width">
<img src="{(_at_)src}" alt="{(_at_)alt(_dot_)text}" border="0" align="{(_at_)align}" width="{(_at_)width}"></img>
                                </xsl:when>
                                <xsl:otherwise>
<img src="{(_at_)src}" alt="{(_at_)alt(_dot_)text}" border="0" align="{(_at_)align}"></img>
                        </xsl:otherwise>
                  </xsl:choose>
                </xsl:if>
  </xsl:template>




  <xsl:template match="header">
        <b><xsl:apply-templates/><br/></b>
  </xsl:template>

</xsl:stylesheet>

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



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