Help with writing select data

P

Patrick

Hi All,

I'm new to all this and I'm back for more help. I am working with global
variables. I'm trying to make my xls just display the data for the
defined <moorname>. In my example I am using the second set of elements
C10AB. I can get it to just show the <moorname> but then it wants to
write out all the values for both sets. How can I fix this.

I would like my output to look like this;

Moorname: C10AB
Moortype: moortype2
Latitude: lat2
Longitude: lon2
Start: start2
End: end2


Your help is greatly appreciated.

Patrick

I have this xml;

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="testglovar.xsl" ?>
<active_wfs>
<deployment>
<moorname>C10AA</moorname>
<moortype>moortype1</moortype>
<lat>lat1</lat>
<lon>lon1</lon>
<start>start1</start>
<end>end1</end>
</deployment>
<deployment>
<moorname>C10AB</moorname>
<moortype>moortype2</moortype>
<lat>lat2</lat>
<lon>lon2</lon>
<start>start2</start>
<end>end2</end>
</deployment>
</active_wfs>


And this xsl;

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:eek:utput method="html" encoding="iso-8859-1"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<xsl:variable name="moorname" select="'C10AB'" >
<html>
<body>
<xsl:call-template name="show_moor">
<xsl:with-param name="moornameToSelect" />
</xsl:call-template>
</body>
</html>
</xsl:variable>

<xsl:template name="show_moor" match="/">
<xsl:param name="moornameToSelect" />
<xsl:for-each select="active_wfs/deployment">
<p>Moorname: <xsl:value-of select="$moorname " /></p>
<p>Moortype: <xsl:value-of select="moortype " /></p>
<p>Latitude: <xsl:value-of select="lat" /></p>
<p>Longitude: <xsl:value-of select="lon" /></p>
<p>Start: <xsl:value-of select="start" /></p>
<p>End: <xsl:value-of select="end" /></p>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

--
Patrick A. Smith Assistant System Administrator
Ocean Circulation Group – USF - College of Marine Science
http://ocgweb.marine.usf.edu Phone: 727 553-3334

The trouble with doing something right the first time is that nobody
appreciates how difficult it was. - La Rochefoucauld
 
J

Joseph Kesselman

Assuming I understand your request:


<xsl:call-template name="show_moor">
<xsl:with-param name="moornameToSelect" selct="$moorname"/>
</xsl:call-template>

You were forgetting to set the actual value of the parameter.


<xsl:for-each select="active_wfs/deployment[moorname=$moornameToSelect]">

Select all those deployments which have a moorname child whose contained
text value is the same as the value you passed in.
 
P

Patrick

Joseph said:
Assuming I understand your request:


<xsl:call-template name="show_moor">
<xsl:with-param name="moornameToSelect" selct="$moorname"/>
</xsl:call-template>

You were forgetting to set the actual value of the parameter.


<xsl:for-each select="active_wfs/deployment[moorname=$moornameToSelect]">

Select all those deployments which have a moorname child whose contained
text value is the same as the value you passed in.


Thanks, that's assuming that I understand what I am trying to do. Can
you give me a more concise example of how this would work as I am at the
point of great confusion here.

Patrick


--
Patrick A. Smith Assistant System Administrator
Ocean Circulation Group – USF - College of Marine Science
http://ocgweb.marine.usf.edu Phone: 727 553-3334

The trouble with doing something right the first time is that nobody
appreciates how difficult it was. - La Rochefoucauld
 
J

Joe Kesselman

Patrick said:
I am working with global variables.

Sorry, I did misread your question. I should learn not to type when tired...
<xsl:variable name="moorname" select="'C10AB'" >
<html>
<body>
<xsl:call-template name="show_moor">
<xsl:with-param name="moornameToSelect" />
</xsl:call-template>
</body>
</html>
</xsl:variable>

This is a problem. You are simultaneously trying to set $moorname to the
literal string C10AB and to contain a Result Tree Fragment which is your
little <html>...</html> block. You can't do both; the variable can have
only one value, and according to the XSLT spec this block of code is an
error -- if the select attribute is specified, the content MUST be empty.

So your first step should be replace that with something legal. Get rid
of either the contents, or the select.


Next step: Decide what your calling sequence is supposed to be here. Are
you really trying to call the same template to build a result tree
fragment in a variable -- which then gets used only to extract the text
nodes back out of it, since that's the definition of value-of when
applied to an RTF -- and as the root template which attempts to use the
result of that variable? Think through what you're trying to do -- write
it out in English -- and then write the code to match it; what you've
got here really does not make any sense, independent of the
global-variable issue.


The parameter you're passing (moornameToSelect) is empty, and unused,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top