xsl-list
[Top] [All Lists]

Re: [xsl] coping with missing external document

2008-07-30 23:45:24
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[(_at_)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



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


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




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--