Newbie Question - This One is Easy.

Discussion in 'XML' started by Larry Lindstrom, Sep 12, 2003.

  1. Hi Experts:

    I've decided to go through ZVON.org's XSLT tutorial.

    The first XSLT example is at:

    www.zvon.org/xxl/XSLTutorial/Output/example1_ch1.html

    Here is the XML, with a reference to the stylesheet
    and other syntactic sugar added at the front:

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="page_01_01.xsl"?>

    <source>

    <title>XSL</title>
    <author>John Smith</author>

    </source>

    Here is the XSL, unchanged from the example:

    <xsl:stylesheet version = '1.0'
    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

    <xsl:template match="/">
    <h1>
    <xsl:value-of select="//title"/>
    </h1>
    <h2>
    <xsl:value-of select="//author"/>
    </h2>
    </xsl:template>

    </xsl:stylesheet>

    The transform to be performed is obvious, but I
    decided to cut and paste it into my website so I
    could watch it work.

    The expected output is "XSL" in H1 font, followed
    on the next line by "John Smith" in H2 font.

    Mozilla 1.3 running on Solaris, displays this as
    "XSLJohn Smith", on the first line, plain text, no
    visible format or font processing.

    Internet Explorer, running on Win 2000, displays
    the XML as expected, with H1 and H2 fonts.

    So, what am I doing wrong?

    A couple of other questions, while I have your
    attention:

    I've looked at Mozilla's tools and haven't been
    able to find anything that will display the XSLT
    output, or the DOM for an XML page. Is there a
    way to see these?

    What do the question marks (<?...?>) in the first
    lines of the XML file signify?

    Thanks
    Larry
     
    Larry Lindstrom, Sep 12, 2003
    #1
    1. Advertising

  2. In article <>,
    Larry Lindstrom <> wrote:

    [...]

    % Here is the XSL, unchanged from the example:
    %
    % <xsl:stylesheet version = '1.0'
    % xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    %
    Try adding

    <xsl:eek:utput method="html"/>

    here. On reflection, since the default should be xml, which in this case
    is close enough, the problem is likely that Mozilla is ignoring the
    xml-stylesheet PI. Does it claim to support it?

    [...]

    % What do the question marks (<?...?>) in the first
    % lines of the XML file signify?

    <? and ?> delimit an XML processing instruction (PI). These are exactly
    that: instructions to the XML processing software, telling it what to
    do with the XML data. PIs starting with `xml' are supposed to have been
    defined by the W3C and one might reasonably expect them to be portable
    across all XML processing software. Other PIs are likely to be specific
    to one program.


    --

    Patrick TJ McPhee
    East York Canada
     
    Patrick TJ McPhee, Sep 12, 2003
    #2
    1. Advertising

  3. In article <>,
    Larry Lindstrom <> wrote:

    > Here is the XML, with a reference to the stylesheet
    >and other syntactic sugar added at the front:


    The output of this stylesheet is an XML document containing

    <h1>XSL</h1><h2>John Smith</h2>

    (not actually a well-formed document because it has two top-level
    elements, but that's not really the problem).

    Mozilla would display this the way you wanted if it believed it
    was HTML or XHTML, but it has no reason to believe this.

    You could do any of the following:

    (a) set the XSL output method to HTML using <xsl:eek:utput method="xml"/>

    (b) wrap an <html> element around the output, which would have the
    side-effect of setting the output method to HTML

    (c) put the <h1> and <h2> elements in the XHTML namespace (and
    preferably wrap them with <html> and <body> elements, and add
    a <head> element, to make it a valid XHTML document)

    -- Richard

    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
     
    Richard Tobin, Sep 12, 2003
    #3
  4. Patrick TJ McPhee wrote:
    >
    > In article <>,
    > Larry Lindstrom <> wrote:
    >
    > [...]
    >
    > % Here is the XSL, unchanged from the example:
    > %
    > % <xsl:stylesheet version = '1.0'
    > % xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
    > %
    > Try adding
    >
    > <xsl:eek:utput method="html"/>
    >
    > here. On reflection, since the default should be xml, which in this case
    > is close enough, the problem is likely that Mozilla is ignoring the
    > xml-stylesheet PI. Does it claim to support it?


    Thanks Again Patrick:

    Your suggestion works.

    I don't know where to find claims of compatibility
    from Mozilla.

    Mozilla has properly displayed XML with other XSL
    files, like the one you helped me with two days ago,
    without that statement.

    W3schools' XSL tutorial shows that xsl:stylesheet
    is recognized by Netscape Navigator 6, which is kind
    of the same as Mozilla. Isn't it?

    Thanks
    Larry
     
    Larry Lindstrom, Sep 12, 2003
    #4
  5. Richard Tobin wrote:
    >
    > In article <>,
    > Larry Lindstrom <> wrote:
    >
    > > Here is the XML, with a reference to the stylesheet
    > >and other syntactic sugar added at the front:

    >
    > The output of this stylesheet is an XML document containing
    >
    > <h1>XSL</h1><h2>John Smith</h2>


    Thanks Richard:

    Is there some way to display XSLT output, in
    Mozilla or IE?

    > (not actually a well-formed document because it has two top-level
    > elements, but that's not really the problem).


    Yea, I see that now. I was being lazy with
    cutting and pasting, and I didn't notice that the
    example was more a code fragment than a proper
    XSL file.

    > Mozilla would display this the way you wanted if it believed it
    > was HTML or XHTML, but it has no reason to believe this.
    >
    > You could do any of the following:
    >
    > (a) set the XSL output method to HTML using <xsl:eek:utput method="xml"/>


    Patrick suggested this, and it works. But I
    know an XSL file is XML, and needs to comply with
    XML's standards.

    > (b) wrap an <html> element around the output, which would have the
    > side-effect of setting the output method to HTML


    This is what I chose to do, I wrapped the XSLT with
    <html> and <body>. That worked.

    > (c) put the <h1> and <h2> elements in the XHTML namespace (and
    > preferably wrap them with <html> and <body> elements, and add
    > a <head> element, to make it a valid XHTML document)


    Namespaces are still a "Do it like the example
    shows and don't worry" kind of thing. I don't
    understand them.

    Thanks
    Larry
     
    Larry Lindstrom, Sep 12, 2003
    #5
  6. In article <>,
    Larry Lindstrom <> wrote:

    >Thanks Richard:
    >
    > Is there some way to display XSLT output, in
    >Mozilla or IE?


    Sorry, don't know. I always run a standalone XSLT processor. But
    that doesn't help you if you suspect that the browser is getting it
    wrong.

    -- Richard
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
     
    Richard Tobin, Sep 12, 2003
    #6
    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. Hazzard
    Replies:
    2
    Views:
    669
    Hazzard
    Apr 6, 2004
  2. =?Utf-8?B?UnlhbiBTbWl0aA==?=

    .NET NEWBIE - EASY QUESTION

    =?Utf-8?B?UnlhbiBTbWl0aA==?=, Apr 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    443
    Matthew Sajdera
    Apr 7, 2004
  3. Bruno Desthuilliers
    Replies:
    5
    Views:
    405
    Bruno Desthuilliers
    Aug 29, 2007
  4. Charles Taylor
    Replies:
    0
    Views:
    134
    Charles Taylor
    Oct 24, 2005
  5. Bender
    Replies:
    4
    Views:
    176
    Bender
    Sep 6, 2003
Loading...

Share This Page