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

Re: Help needed with converting to (patterned) Element

Subject: Re: Help needed with converting to (patterned) Element content to sub-elements only
From: Ken Starks <ken@xxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 25 Jan 2009 17:49:43 +0000
Re:  Help needed with converting to (patterned) Element
George Cristian Bina wrote:
Hi,

That is easy with XSLT 2.0, see below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output indent="yes"/>
<xsl:template match="coordinate">
<FullCoordinates datum="WGS84">
<xsl:for-each select="tokenize(normalize-space(.), ' ')">
<xsl:variable name="values" select="tokenize(., ',')"/>
<Point longitude="{$values[1]}" latitude="{$values[2]}">
<xsl:if test="$values[3]"><xsl:attribute name="ht_above_geoid" select="$values[3]"/></xsl:if>
</Point>
</xsl:for-each>
</FullCoordinates>
</xsl:template>
</xsl:stylesheet>


on

<coordinate>
    aaa,bbb,ccc
    ddd,eee,fff  ggg,hhh    jjj,kkk,lll
</coordinate>

gives

<?xml version="1.0" encoding="UTF-8"?>
<FullCoordinates datum="WGS84">
   <Point longitude="aaa" latitude="bbb" ht_above_geoid="ccc"/>
   <Point longitude="ddd" latitude="eee" ht_above_geoid="fff"/>
   <Point longitude="ggg" latitude="hhh"/>
   <Point longitude="jjj" latitude="kkk" ht_above_geoid="lll"/>
</FullCoordinates>


Best Regards, George -- George Cristian Bina <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com

That's fabulous, George, thanks very much.

By the way, I am a user of  <oXygen/> XML Editor, and very happy with it,
even though I am still only using a small fraction of its functionality.

Sincerely,
Ken.

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.