WEB Unable to get XML/XSLT showing.

Discussion in 'OT Technology' started by Swerve, Jan 25, 2009.

  1. Swerve

    Swerve OT Supporter

    Joined:
    Feb 20, 2005
    Messages:
    3,175
    Likes Received:
    3
    I've been trying to get this XML data to show in a webpage, but I'm doing something obvious wrong, but I'm totally failing to get it to work..

    The site uses an external CSS page to style it, BUT I want to show some XML data in the mainContent DIV, and style the XML with the XSLT stylesheet, not the CSS stylesheet.

    .html file:
    XML file:
    .xsl file:
    Can anyone see what I'm doing wrong?

    I simply wanted the text in bold to show, styled by the .xsl file, but it not :wtc:
     
    Last edited: Jan 25, 2009
  2. Swerve

    Swerve OT Supporter

    Joined:
    Feb 20, 2005
    Messages:
    3,175
    Likes Received:
    3
    In an attempt to narrow down the problem, I have made the three following files in a separate folder on the server.

    I am trying to display the data in the .xml file, and have it styled by the .xsl file. In this try I am trying to make the text yellow.

    .xml file:
    .html file:

    .xls file:
    -----------------------------------------

    With Firefox, when I view folder/basic.html I see:
    When I view the folder/basic.xml I see:

    But how can I view the .xml, styled with the .xls, inside the .html page?

    I want to put it inside a DIV on the .html page, which is completely styled with CSS.

    The .xls style needs to override the CSS somehow.

    Or does the user have to view the .xml page, is it not possible to show XML in a URL ending with .html?

    I have never viewed a webpage ending with .xml before I don't think, so I am believing it is possible.
     
    Last edited: Jan 25, 2009
  3. Swerve

    Swerve OT Supporter

    Joined:
    Feb 20, 2005
    Messages:
    3,175
    Likes Received:
    3
    and if I rename the .hml file to a .xhtml file, and view that through Firefox I get the following:

     
  4. whup

    whup I wish you had children and.. so that I could step

    Joined:
    Feb 12, 2007
    Messages:
    1,603
    Likes Received:
    0
    I really don't think you can embed XML in HTML like that and get it to render properly.

    I'd recommend you use a library like Sarissa. It will let you dynamically load in the XML and XSLT and insert the transformed results into a div for example.

    Drop the HTML and BODY elements from XSLT too, just stick to simple elements; an HTML page is only meant to have one instance of the latter.

    http://dev.abiss.gr/sarissa/howtos.html
     
  5. 95vr4

    95vr4 OT Supporter

    Joined:
    Oct 6, 2004
    Messages:
    2,513
    Likes Received:
    0
    Location:
    Weddington, NC
    <?xml version="1.0"?> always has to be the first line of the file.


    I've never been much of a fan of XML style sheets personally. XML is great for data exchange, I just prefer good old css and mysql for the separate content/style type tasks.
     
  6. Swerve

    Swerve OT Supporter

    Joined:
    Feb 20, 2005
    Messages:
    3,175
    Likes Received:
    3
    Thank you guys for the clarification. This was most frustrating yesterday.

    I have to agree, the more traditional CSS/MySQL method is much more simple. I will checkout Sarissa today, it's not something I've heard of before.

    Appreciated.
     

Share This Page