Altova Mailing List Archives


RE: [xsl] sql if exists

From: "Michael Kay" <mike@------------>
To:
Date: 4/15/2009 8:09:00 AM
Sure. You can do it at the XSLT level

<xsl:choose>
  <xsl:when test="exists(/a/b/c)">
    <...>
  </xsl:when>
  <xsl:otherwise>
    <...>
  </xsl:otherwise>
</xsl:choose>

or at the XPath level:

select="if (exists(/a/b/c)) then ... else ..."

In practice people often leave out the call to exists() because the
effective boolean value of a node-sequence is true if it's non-empty, so
this is equivalent to test="/a/b/c".

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Szabo, Patrick (LNG-VIE) [mailto:patrick.szabo@xxxxxxxxxxxxx]
> Sent: 15 April 2009 08:32
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] sql if exists
>
> Hi,
>
> I4m using saxon 9 and xslt 2.
>
> I want to insert data into a database with my xslt-sheet
> which is no problem. The problem is that i only want to do
> that under certain conditions.
>
> In SQL that4d look like this:
>
> "IF EXISTS ( select * from...)
> 	Do something
> ELSE
> 	do something else"
>
> Is there a way to use that code in my xslt-sheet ?!
>
> Currently i4m using
> "java:/net.sf.saxon.sql.SQLElementFactory" to insert
> something at all.
>
> Thx already
>
> cheers
>
> Patrick Szabo
> EPD / XSLT Konvertierung
> Tel.: +43-1-534 52-1573
> Fax.: +43-1-534 52-1573
> patrick.szabo@xxxxxxxxxxxxx
>
> LexisNexis Verlag ARD Orac GmbH & Co KG
> Marxergasse 25, 1030 Wien
> FN 8333f, Handelsgericht Wien
> www.lexisnexis.at <http://www.lexisnexis.at/>
>
>  <file://C:\Dokumente und
> Einstellungen\szaboP\Anwendungsdaten\Microsoft\Signatures\LN
> Vienna signature-Dateien\image001.jpg>
>
>
>
>
> Patrick Szabo
> XSLT-Entwickler
>
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146
>
> Patrick.Szabo@xxxxxxxxxxxxx
>
> LexisNexis Verlag ARD Orac GmbH & Co KG
> Marxergasse 25, 1030 Wien
> FN 8333f, Handelsgericht Wien
> http://www.lexisnexis.at/

Disclaimer

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.