xsl-list
[Top] [All Lists]

RE: [xsl] sql if exists

2009-04-15 04:31:38
Oh I see what you want.

You can do test="exists(my:sql-query($connection))" and then write a
user-defined function 

<xsl:function name="my:sql-query">
  <xsl:param name="connection"/>
  <saxon:query..../>
</xsl:function> 

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

-----Original Message-----
From: Szabo, Patrick (LNG-VIE) 
[mailto:patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at] 
Sent: 15 April 2009 09:23
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: AW: [xsl] sql if exists

Sorry but i don´t really understand what you mean. 

Dou you mean...

<xsl:choose>
  <xsl:when test="exists("SELECT STATEMENT")">
    <...>
  </xsl:when>
  <xsl:otherwise>
    <...>
  </xsl:otherwise>
</xsl:choose>  

???

I think i didn´t make myself clear.

What i want to do:

First i want to check if a certain row already exists in the DB.
If that is not the case i want to insert that row.  

cheers

Patrick Szabo
EPD / XSLT Konvertierung
Tel.: +43-1-534 52-1573
Fax.: +43-1-534 52-1573
patrick(_dot_)szabo(_at_)lexisnexis(_dot_)at

LexisNexis Verlag ARD Orac GmbH & Co KG
Marxergasse 25, 1030 Wien
FN 8333f, Handelsgericht Wien
www.lexisnexis.at






Patrick Szabo
XSLT-Entwickler

Tel.: +43 (1) 534 52 - 1573
Fax: +43 (1) 534 52 - 146

Patrick(_dot_)Szabo(_at_)lexisnexis(_dot_)at

LexisNexis Verlag ARD Orac GmbH & Co KG
Marxergasse 25, 1030 Wien
FN 8333f, Handelsgericht Wien
http://www.lexisnexis.at/
 
-----Ursprüngliche Nachricht-----

Von: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com]
Gesendet: Mittwoch, 15. April 2009 10:09
An: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Betreff: RE: [xsl] sql if exists

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(_dot_)szabo(_at_)lexisnexis(_dot_)at]
Sent: 15 April 2009 08:32
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] sql if exists

Hi,
 
I´m 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 that´d 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 i´m 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(_dot_)szabo(_at_)lexisnexis(_dot_)at

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(_dot_)Szabo(_at_)lexisnexis(_dot_)at

LexisNexis Verlag ARD Orac GmbH & Co KG Marxergasse 25, 
1030 Wien FN 
8333f, Handelsgericht Wien http://www.lexisnexis.at/
 





--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--



--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>