Forum Stats

  • 3,875,866 Users
  • 2,266,977 Discussions
  • 7,912,359 Comments

Discussions

How Can I dispaly XML file with CSS?

843834
843834 Member Posts: 49,972
edited Jul 25, 2001 4:09AM in Java Technology & XML
hi,all
There is maybe a simple way to dispaly a XML file with a CSS file in program.But I don't know.Who can tell me?
Thank you very much!

Comments

  • 843834
    843834 Member Posts: 49,972
    Hello -

    I am not 100% sure on your question. What I will tell you is that the usual manner in which you would render an XML document for display would be with an XSLT stylesheet.

    XSLT is another open source standard that is based on XML. I have used this combination quite a few times now and appreciate the flexibility that you get. The downside is that currently you need to send the XML to either a JSP or servlet that will translate and then output the transformed text.

    If you have more questions let me know.
    -Mike
  • 843834
    843834 Member Posts: 49,972
    hello,
    Thank you for your reply!
    I know that XSLT can translate a XML file and a XSL file into other format,including HTML.But comparing with CSS,it's is difficult to manipulate XSL.For example,you dispaly a XML file in a JTextPane and allow users to edit it's content and appearance.If use css,when the appearance is changed,you can log it easily by writing the information into CSS file.If use XSL,logging the information would be difficult.In addition,many people are good at CSS,but they don't know XSL.I want my program to support both XSL and CSS. so I want to Know how to display XML file with CSS.
    Thank you again!
  • 843834
    843834 Member Posts: 49,972
    Hi,

    XML documents don't have the link or style elements that are used in HTML to connect style information to particular documents. Instead, the W3C has defined a processing instruction that provides that information, based on the model of the HTML link element. To connect a CSS style sheet to your XML document so that the browser can find it, use a processing instruction like

    <?xml-stylesheet type="text/css" href="URI"?>

    where URI is the address of the style sheet. We'll use a style sheet called display1.css for our first test document. The processing instruction can go right after the XML declaration.

    <?xml version="1.0" ?>
    <?xml-stylesheet type="text/css" href="display1.css"?>
    <test>


    Hope this may help you.

    Regards,
    Anil.
    Technical Support Engineer.

  • 843834
    843834 Member Posts: 49,972
    Thank ramanil_indts.But how can I achieve it by using Java,just like the Morphon XMLEditor?
    Thank you again!
This discussion has been closed.