[Home] [By Thread] [By Date] [Recent Entries]
You could use something like this:
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet exclude-result-prefixes="#all" version="2.0" xmlns:f="funtions" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="node()|@*"> <xsl:apply-templates select="node()|@*"/> </xsl:template> <xsl:function name="f:coord">
<xsl:param name="input"/>
<xsl:for-each select="tokenize(data($input),'[. ]')">
<xsl:choose>
<xsl:when test="position()=1">
<xsl:value-of select="."/>
<xsl:text>deg </xsl:text>
</xsl:when>
<xsl:when test="position()=2">
<xsl:value-of select="."/>
<xsl:text>min </xsl:text>
</xsl:when>
<xsl:when test="position()=3">
<xsl:value-of select="."/>
<xsl:text>sec </xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:function> <xsl:template match="location">
<output>
<Data><xsl:value-of select="f:coord(@latitude)"/></Data>
<Data><xsl:value-of select="f:coord(@longitude)"/></Data>
</output>
</xsl:template></xsl:stylesheet> Using your '<location latitude="34.56.12 N" longitude="125.6.15 E"/>' input, the output would look like this: <?xml version="1.0" encoding="UTF-8"?>
<output>
<Data>34deg 56min 12sec N</Data>
<Data>125deg 6min 15sec E</Data>
</output>cknell@xxxxxxxxxx wrote: I'm still knocking the rust off my brain and I've go to the point where I wish to split the value of an attribute and concatenate the pieces to return a second string.
|

Cart



