ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Frank Carver <fr...@efsol.com>
Subject RE: Generating relative paths with XSLT
Date Sun, 17 Nov 2002 19:54:20 GMT

Scott Stirling <scottstirling@rcn.com> said:
> Please explain what you mean.  Do you get errors during transformation?
> Not sure what the real problem is.  How exactly do the relative hrefs in
> the input XML differ from the output HTML?

Ah.  Sorry for the confusion.  My input documents have no references, relative
or otherwise.  The references are part of the style, and described in the
stylesheet.  Here's a simplified example:

file ./index.xml:

  <page title='home page'>
  <p>Welcome to my statically-styled web site!</p>
  <p>See our <a href='products/special.html">Special Offer</a></p>
  </page>

file products/special.xml:

  <page title='special offers'>
  <p><b>Today Only!</b> Widgets at $39/kg</p>
  </page>

I wish to apply the same stylesheet to both these pages (and lots of others, of
course).  Something like:

file default.xsl: (trimmed a lot from the real one, and not syntax checked!)

  <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" encoding="8859-1"/>
  <xsl:template match="page">
  <html><head><title><xsl:value-of select="@title"/></title></head><body>
  <h2><img src='images/logo.gif'/> <xsl:value-of select="@title"/></h2>
  <xsl:apply-templates select="node()"/>
  </body></html>
  </xsl:template>

  <xsl:template match="@*|node()|processing-instruction()|comment()">
   <xsl:copy>
    <xsl:apply-templates select="@*|node()|processing-instruction()|comment()"/>
   </xsl:copy>
  </xsl:template>
  </xsl:stylesheet>

The problem occurs with the reference to images/logo.gif.  It works fine for
pages at the "top level" (such as index.html, above).  But pages in
subdirectories (such as products/special.xml, above) would really need
to generate something like "../images/logo.gif".

Is that clearer ?

Thanks for your interest.


--
Frank Carver   frank@efsol.com   http://www.efsol.com/


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message