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

build a select clause or dynamic URI's

Subject: build a select clause or dynamic URI's
From: Andy Dent <dent@xxxxxxxxxxxxx>
Date: Wed, 10 Nov 2004 07:52:24 +0800
xsl select or
I'm trying to construct some generic XSLT patterns for processing
typical GML documents and am struggling with a dynamic path following
issue. I've over 20 years in software development and a moderate XSLT
semantic understanding but am not yet at guru level. The num2cells
template at the end of this message is about as good as I've got :-)

I don't know if this is possible in generic XSLT. As these are samples expected to be used by a wide community, I'm trying to avoid extensions.

I summarise what I need as wanting to go from a string value in an
attribute to having the nodeset it refers to. So, given an href like
"../../../gml:position" I can write a generic template to invoke the
original gml:position template.

I've experimented with the document function and just had someone else suggest it may help but I'm not sure how to use document to refer to a different location in the current source.

Say we have some XML with a relative ref back in the file, like:
             <featureMember>
                         <GeochemSpecimen gml:id="WA_1_139459">
                                     <gml:name>139459</gml:name>
                                     <gml:position
xlink:href="urn:x-seegrid:definition:gml:NilReason:unknown"/>
                                     <material>rock</material>
                                     <relatedObservation>
                                                 <GeochemMeasurement
gml:id="WA_1_139459_Ag">

<gml:position xlink:href="../../../gml:position"/>


I'm processing this with <xsl:apply-templates select="gml:position"/> invoking the following

             <xsl:template match="gml:position">
                         <xsl:choose>
                                     <xsl:when
test="contains(@xlink:href,'gml:position')">
                                     <!-- ref to another position, eg:
@xlink:href='../../../gml:position'-->
<!-- literal select works     <xsl:apply-templates
select='../../../gml:position'/> -->
                                     </xsl:when>
                                     <xsl:when
test="@xlink:href='urn:x-seegrid:definition:gml:NilReason:unknown'">
                                                 <td
colspan="3">unknown</td>
                                     </xsl:when>
                                     <xsl:when test="gml:Point/gml:pos">
                                                 <xsl:call-template
name="num2cells">

<xsl:with-param name="numbers"
select="normalize-space(gml:Point/gml:pos)"/>

<xsl:with-param
name="colsToFill" select="3"/>
                                                 </xsl:call-template>
                                     </xsl:when>
                                     <xsl:otherwise>
                                                 <td
colspan="3">unrecognised gml:position</td>
                                     </xsl:otherwise>
                         </xsl:choose>
             </xsl:template>


<!-- Recursively parse a space-delimited list into <td> pairs, assumes single whitespace delimiters, puts colspan on blank last entry if necessary, pass in 0 to colsToFillif don't care about padding --> <xsl:template name="num2cells"> <xsl:param name="numbers"/> <xsl:param name="colsToFill"/> <xsl:choose> <xsl:when test="contains($numbers,' ')"> <td>

<xsl:value-of select="substring-before($numbers, ' ')"/>
                                                 </td>
                                                 <xsl:call-template
name="num2cells">

<xsl:with-param name="numbers" select="substring-after($numbers, ' ')"/>

<xsl:with-param
name="colsToFill" select="number($colsToFill)-1"/>
                                                 </xsl:call-template>
                                     </xsl:when>
                                     <xsl:when test="$colsToFill>2">
                                                 <td><xsl:value-of
select="$numbers"/></td><td colspan="{$colsToFill-1}">&nbsp;</td>
                                     </xsl:when>
                                     <xsl:when test="$colsToFill=2">
                                                 <td><xsl:value-of
select="$numbers"/></td><td>&nbsp;</td>
                                     </xsl:when>
                                     <xsl:otherwise> <!-- exact fit or
more cols thanexpected -->
                                                 <td><xsl:value-of
select="$numbers"/></td>
                                     </xsl:otherwise>
                         </xsl:choose>
             </xsl:template>


Thanks for any advice



--


Andy Dent BSc  MACS   http://www.oofile.com.au/
OOFILE - Database, Reports, Graphs, GUI for c++ on Mac, Unix & Windows
PP2MFC - PowerPlant->MFC portability

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-2011 All Rights Reserved.