|
Subject: Re: [xsl] check if document exists From: "Albert Juhé" <albertjuhe@xxxxxxxxx> Date: Tue, 25 Jul 2006 09:19:58 +0200 |
I've had a similar problem, I needed to test an image file exists and if exists I needed width and height.
<xsl:template name="file-exists" xmlns:file="java.io.File"> <xsl:param name="filename"/> <xsl:value-of select="file:exists(file:new($filename))"/> </xsl:template>
<xsl:template name="image-size" xmlns:java="xalan://javax.swing.ImageIcon"> <xsl:param name="mida" select="'width'"/> <xsl:param name="filename"/>
<xsl:if test="normalize-space($filename)">
<xsl:variable name="imatge" select="java:new($filename)"/>
<!-- Extract image file info -->
<xsl:choose>
<xsl:when test="$mida='width'">
<xsl:value-of select="java:getIconWidth($imatge)"/>
</xsl:when>
<xsl:when test="$mida='height'">
<xsl:value-of select="java:getIconHeight($imatge)"/>
</xsl:when>
<xsl:when test="$mida='mida'">
<xsl:value-of
select="java:getIconHeight($imatge)*java:getIconWidth($imatge)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="-1"/>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:template>
Albert Juhi www.omaonk.com
I am having a similar problem in xslt 1.0 (MSXML).
We have a supplier ftp'ing some XML data but sometimes it doesnt arrive and sometimes its invalid XML :(
Ive tried
<xsl:if test="msxsl:node-set(document('..\weather\weather.xml'))"> and <xsl:if test="document('..\weather\weather.xml')">
but both throw errors and the template stops.
Is there any way I can test the validity of the document to be imported and handle it gracefully?
Cheers
Cheers
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] check if document exists, Michael Kay | Thread | Re: [xsl] check if document exists, Todd Baker |
| Re: [xsl] Comparing to SQL NULL, Florent Georges | Date | Re: [xsl] check if document exists, Todd Baker |
| Month |