[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl split string

Subject: RE: xsl split string
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 11 Dec 2005 23:58:02 -0000
xsl split
In XSLT 2.0, use the tokenize() function.

With XSLT 1.0, try the str:tokenize template found at http://www.exslt.org/

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

> -----Original Message-----
> From: Philippe LAPLANCHE [mailto:philippe.laplanche@xxxxxxxxxxxx]
> Sent: 11 December 2005 20:13
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  xsl split string
>
> Hi
>
> I have to transform this "compressed" xml :
>
> <root fields="CHP-CODE|CHP-TABLE|CHP-LIBELLE">
>          <update xi="5" xk="5" a="CHP-ORDRE" b="champs" c="Ordre"/>
> </root>
>
>
> Into this :
>
> <page>
> 	<sql:execute-query xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> 		<sql:querry>
> 			UPDATE `config`
> 				SET `CHP-CODE`='CHP-ORDRE',
> 				    `CHP-TABLE`='champs',
> 				    `CHP-LIBELLE`='Ordre'
> 				WHERE UID='5'
> 		</sql:querry>
> 	</sql:execute-query>
> </page>
>
> My problem is that I don't know how to extract CHP-CODE,
> CHP-TABLE and CHP-LIBELLE from the fields attribute of the
> root node. I have to do something generic that would work if
> the fields attribute is longer.
>
> For now I have this stylesheet. I just don't know how to
> complete the part where I put ......
>
> 	<xsl:template match="/root">
> 		<page>
> 			<xsl:apply-templates select="*"/>
> 		</page>
> 	</xsl:template>
>
> 	<xsl:template match="update">
> 		<sql:execute-query
> xmlns:sql="http://apache.org/cocoon/SQL/2.0">
> 			<sql:query>
> 				UPDATE `config`
> 				SET <xsl:apply-templates
> select="@*[not(name()='xk' or name()='xi')]" mode="update"/>
> 				WHERE <xsl:apply-templates
> select="@xk" mode="update"/>
> 			</sql:query>
> 		</sql:execute-query>
> 	</xsl:template>
>
> 	<xsl:template match="@*" mode="update">
> 		`..........` = '<xsl:value-of select="."/>'
> <xsl:if test="not(position()=last())">,</xsl:if>
> 	</xsl:template>
>
>
> Philippe

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.