Re: [xsl] coping with missing external document

Subject: Re: [xsl] coping with missing external document
From: Jeff Sese <jeferson.sese@xxxxxxxxxxxx>
Date: Thu, 31 Jul 2008 14:48:00 +0800
try the doc-available(URI) function...

-- Jeff

On 07 31, 08, at 2:14 PM, Trevor Nicholls wrote:

I have a v1.0 stylesheet which fills in cross-reference text by looking up
an external document, using the following template rule:


 <!-- external cross references -->
 <xsl:template match="jump[@srcfile]">
  <xsl:variable name="jfil" select="substring-before(@srcfile,'#')" />
  <xsl:variable name="jid" select="substring-after(@srcfile,'#')" />
  <xsl:copy>
   <xsl:attribute name="text">
    <xsl:for-each select="document($jfil,/)">
     <xsl:value-of select="normalize-space(id($jid))" />
    </xsl:for-each>
   </xsl:attribute>
  </xsl:copy>
 </xsl:template>

If the external document does not exist I would like the template to copy
the jump element and give it an empty text attribute, without generating an
error. However this isn't what happens when the stylesheet is run. If the
external document is missing the transformation stops with an error, which
is unfortunate because the main purpose of the stylesheet is to transform a
document written by FrameMaker so that it is translated from one schema to
another. If the transformation fails the document is left in an invalid
state. The XSL processor is Xalan.


Is there anything I can add to the template, or stylesheet, so that this
situation does not generate a fatal error?


Cheers
Trevor


Jeferson L. Sese jeferson dot sese at asiatype dot com Asiatype Inc. Suite 114 Columbia Tower Ortigas Ave., Greenhills Mandaluyong City 1550 Philippines Tel: +632-744-6262 Mobile: +63927-671-7901

Current Thread