Dispaly specific sections of xml document

P

Patrick

Hi All.

I'm newish to xml/xsl so forgive me if this has been discussed before. I
tried to google the info, but I'm not sure about terminology. So I am
looking for input on a solution or a link to a previous thread. Let me
see now if I can set up my question correctly.

Here is an example of my xml;

<active_wfs>
<deployment>
<moorname>C10AA</moorname>
<moortype>Surface Buoy with ADCP</moortype>
<lat>27 07.475' N</lat>
<lon>82 52.525' W</lon>
<start>1400 September 14th, 1998</start>
<end>1200 November 24th, 1998</end>
</deployment>
<deployment>
<moorname>C10AB</moorname>
<moortype>Surface Buoy with ADCP</moortype>
<lat>27 07.487' N</lat>
<lon>82 52.527' W</lon>
<start>1600 November 24th, 1998</start>
<end>0800 March 13th, 1999</end>
</deployment>

Now what I am trying to do. I am building a web based form in which a
user will select a specific mooring. In the example C10AA and C10AB are
available. In the working version I will have approximately 75
deployments to choose from. Ideally the form will pass the value of
<moorname> to the xsl which will in turn display just the data from that
section of the xml on a web page. Can this be done using xml/xsl. Right
now I can display the entire xml document, but not individual parts. I
guess what I want to do is something like;

if $passed_value == <moorname> then write values to end of </moorname>


I hope I did okay in explaining myself. Any help would be appreciated.

Regards,
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
 
M

Martin Honnen

Patrick said:
Now what I am trying to do. I am building a web based form in which a
user will select a specific mooring. In the example C10AA and C10AB are
available. In the working version I will have approximately 75
deployments to choose from. Ideally the form will pass the value of
<moorname> to the xsl which will in turn display just the data from that
section of the xml on a web page. Can this be done using xml/xsl.

Yes, certainly, define a global parameter in the stylesheet with e.g.
<xsl:param name="moornameToSelect"/>
as a top level element (child of xsl:stylesheet), then look into the API
of the XSLT processor you use on how to set global parameters before you
run a transformation.

In the XSLT stylesheet you then simply do e.g.
<xsl:apply-templates select="deployment[moorname = $moornameToSelect]"/>
to only process the deployment element with the moorname value you are
passing in as a parameter.
 
P

Patrick

Martin said:
Patrick said:
Now what I am trying to do. I am building a web based form in which a
user will select a specific mooring. In the example C10AA and C10AB
are available. In the working version I will have approximately 75
deployments to choose from. Ideally the form will pass the value of
<moorname> to the xsl which will in turn display just the data from
that section of the xml on a web page. Can this be done using xml/xsl.


Yes, certainly, define a global parameter in the stylesheet with e.g.
<xsl:param name="moornameToSelect"/>
as a top level element (child of xsl:stylesheet), then look into the API
of the XSLT processor you use on how to set global parameters before you
run a transformation.

In the XSLT stylesheet you then simply do e.g.
<xsl:apply-templates select="deployment[moorname = $moornameToSelect]"/>
to only process the deployment element with the moorname value you are
passing in as a parameter.

Hmm, okay, I kind of get what you are saying so it gives me an idea
where to start and what to google for example code. Seems like that's
the way I learn. I see an example and then make it work for my stuff.

Thanks for your help.
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
 
M

Martin Honnen

Patrick said:
Hmm, okay, I kind of get what you are saying so it gives me an idea
where to start and what to google for example code.

My post had example code in terms of the XSLT stylesheet. Of course you
will also need code to run the transformation and to set the parameter
before doing that but that depends on the programming language and XSLT
processor respectively server side framework (e.g. ASP or JSP or PHP)
you use. Members of this group might be able to help with that if you
tell us what you use/want to use.
 
P

Patrick

Martin said:
My post had example code in terms of the XSLT stylesheet. Of course you
will also need code to run the transformation and to set the parameter
before doing that but that depends on the programming language and XSLT
processor respectively server side framework (e.g. ASP or JSP or PHP)
you use. Members of this group might be able to help with that if you
tell us what you use/want to use.

Martin,

Yes, your post did have example code and thank you. That's what I meant
in terms of giving me and idea of what to look for. I have already
googled "xsl global parameter" to read up on that a bit. What I am going
to look for is complete code examples similar to what I am going to do.
Yes, I will be using PHP to glue it all together. I do sincerely
appreciate your taking the time to lend me your expertise and more than
likely will be back with other questions for the group.

Regards,
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
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top