Dispaly specific sections of xml document

Discussion in 'XML' started by Patrick, Oct 31, 2006.

  1. Patrick

    Patrick Guest

    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
    Patrick, Oct 31, 2006
    #1
    1. Advertising

  2. Patrick wrote:

    > 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.




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 31, 2006
    #2
    1. Advertising

  3. Patrick

    Patrick Guest

    Martin Honnen wrote:

    > Patrick wrote:
    >
    >> 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
    Patrick, Oct 31, 2006
    #3
  4. Patrick wrote:

    > 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.


    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 31, 2006
    #4
  5. Patrick

    Patrick Guest

    Martin Honnen wrote:

    > Patrick wrote:
    >
    >> 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.
    >
    >


    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
    Patrick, Oct 31, 2006
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack David

    Dispaly a page to a specific user

    Jack David, Jul 13, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    350
    Edwin Kusters
    Jul 13, 2003
  2. Shankar kalel
    Replies:
    1
    Views:
    466
    Joerg Jooss
    Dec 30, 2003
  3. Tony Prichard
    Replies:
    0
    Views:
    723
    Tony Prichard
    Dec 12, 2003
  4. Raman
    Replies:
    6
    Views:
    4,718
    santosh
    Aug 3, 2007
  5. Jeff Higgins
    Replies:
    1
    Views:
    308
    Jeff Higgins
    Jun 24, 2012
Loading...

Share This Page