Closed Thread
Results 1 to 3 of 3

Thread: XML, XSL and Javascript

  1. #1
    BlackCaesar is offline Newbie
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    XML, XSL and Javascript

    I hope I explain this properly.

    What I currently have is a xml file (which looks something like this). We'll call it "index.xml":

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <site>
      <home>  
        <page>
          <pagetitle>Home</pagetitle>
          <pagedata>
            <information>lorem ipsum...</information>
            <description>lorem ipsum...</description>
          </pagedata>
        </page>
      <home>
    
        [...]
    
      <contact>  
        <page>
          <pagetitle>Contact</pagetitle>
          <pagedata>
            <information>lorem ipsum...</information>
            <description>lorem ipsum...</description>
          </pagedata>
        </page>
      <contact>
    
      <legal>  
        <page>
          <pagetitle>Legal</pagetitle>
          <pagedata>
            <information>lorem ipsum...</information>
            <description>lorem ipsum...</description>
          </pagedata>
        </page>
      <legal>
    </site>
    I have the ability to display certain pieces of the XML file using XSL. I have one XSL file for each page in the XML file (Home, Contact, Legal, etc.). What I would like to accomplish is setting up my navigation to not change XML files but to change the XSL file it references to.

    So I guess it'd be something along the lines of a link that triggers an event. The event is the change of the XSL stylesheet that the XML file references to. By doing so, you should now be able to display the data you want, without changing XML files.

    What would be the best way to accomplish this?

    I was thinking somewhere along the lines of making a master XSL file that includes all of page XSL files and using a javascript function to switch the XSL stylesheet (Similar to how you would change a CSS stylesheet).

    Any ideas?

    EDIT: For clarity and mistakes

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Sep 2007
    Location
    Karlstad, Sweden
    Posts
    3,082
    Blog Entries
    7
    Rep Power
    42

    Re: XML, XSL and Javascript

    I'm not into XML - XLS at all, but what if you just use different tags in the different pages? can't you load them all then?
    __________________________________________
    I study Information Systems at Karlstad University when I'm not on CodeCall

  4. #3
    BlackCaesar is offline Newbie
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Re: XML, XSL and Javascript

    Quote Originally Posted by Orjan View Post
    I'm not into XML - XLS at all, but what if you just use different tags in the different pages? can't you load them all then?
    Blah... I made a mistake in the way I structured the XML file in my example.. just let me edit that first.

    I'm not trying to load them all though. I'm trying to load them separately. For instance, right now my "Home" XSL page would look something like this:

    Code:
    [...]
    <xsl:for-each select="site/home/page">
                <h1><xsl:value-of select="pagetitle" /></h1>
    </xsl:for-each>
    [...]
    This will only select the info under the home/page's child nodes. Each XSL sheet shows different info from the same same XML file. I just want a way to give the user the ability to switch XSL stylesheets associated with the XML file.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. javascript help
    By -Hurricane- in forum JavaScript and CSS
    Replies: 3
    Last Post: 05-06-2010, 06:53 AM
  2. javascript help
    By hkp in forum JavaScript and CSS
    Replies: 2
    Last Post: 06-04-2009, 11:55 PM
  3. JavaScript
    By Bannana97 in forum JavaScript and CSS
    Replies: 5
    Last Post: 02-19-2009, 03:54 AM
  4. C++ and JavaScript
    By aloplop in forum C and C++
    Replies: 0
    Last Post: 09-22-2008, 07:24 AM
  5. CRC (JavaScript)
    By RobotGymnast in forum JavaScript and CSS
    Replies: 3
    Last Post: 04-21-2008, 01:02 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts