Xml+XSL: Problems with FireFox displaying

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jesper Stocholm

    Xml+XSL: Problems with FireFox displaying

    I have som XML that link to an XSL-file to enable on-the-fly
    HTML-generation by e.g. IE or FireFox. The transformation actually works
    like a charm, but I have problems with changing line breaks in the XML to
    their html-equivilant <br/>.

    I use the XSL:

    <xsl:template name="break">
    <xsl:param name="text" select="."/>
    <xsl:choose>
    <xsl:when test="contains( $text, '&#xa;')">
    <xsl:value-of select="substri ng-before($text, '&#xa;')"/>
    <br/>
    <xsl:call-template name="break">
    <xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
    </xsl:call-template>
    </xsl:when>
    <xsl:otherwis e>
    <xsl:value-of select="$text"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:template>

    And I apply it to the specific XML-element with the code

    <xsl:call-template name="break">
    <xsl:with-param name="text" select="descrip tion"/>
    </xsl:call-template>

    When I display the XML-file in IE, it all looks fine and dandy - but when I
    load the page in FireFox (1.0 PR), the linebreaks are not converted to
    html-<br>-tags.

    What am I doing wrong?

    And - are there some programs out there that will allow me to supply a
    XML-file and a XSL-stylesheet - and then display the result of the
    XSL(T)-transaformation ?

    --
    Jesper Stocholm


    "Man knepper ikke en anden ridders mø"
  • Martin Honnen

    #2
    Re: Xml+XSL: Problems with FireFox displaying



    Jesper Stocholm wrote:[color=blue]
    > I have som XML that link to an XSL-file to enable on-the-fly
    > HTML-generation by e.g. IE or FireFox. The transformation actually works
    > like a charm, but I have problems with changing line breaks in the XML to
    > their html-equivilant <br/>.
    >
    > I use the XSL:
    >
    > <xsl:template name="break">
    > <xsl:param name="text" select="."/>
    > <xsl:choose>
    > <xsl:when test="contains( $text, '&#xa;')">
    > <xsl:value-of select="substri ng-before($text, '&#xa;')"/>
    > <br/>
    > <xsl:call-template name="break">
    > <xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
    > </xsl:call-template>
    > </xsl:when>
    > <xsl:otherwis e>
    > <xsl:value-of select="$text"/>
    > </xsl:otherwise>
    > </xsl:choose>
    > </xsl:template>
    >
    > And I apply it to the specific XML-element with the code
    >
    > <xsl:call-template name="break">
    > <xsl:with-param name="text" select="descrip tion"/>
    > </xsl:call-template>
    >
    > When I display the XML-file in IE, it all looks fine and dandy - but when I
    > load the page in FireFox (1.0 PR), the linebreaks are not converted to
    > html-<br>-tags.
    >
    > What am I doing wrong?[/color]

    Hard to tell, maybe you can post the URLs of a short XML sample and XSLT
    demonstrating the problem. I see nothing wrong in that XSLT snippet you
    have above but the problem could be with your XML input.


    --

    Martin Honnen

    Comment

    • Jesper Stocholm

      #3
      Re: Xml+XSL: Problems with FireFox displaying

      On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
      [color=blue]
      > Jesper Stocholm wrote:[/color]
      [color=blue][color=green]
      >> What am I doing wrong?[/color]
      >
      > Hard to tell, maybe you can post the URLs of a short XML sample and XSLT
      > demonstrating the problem. I see nothing wrong in that XSLT snippet you
      > have above but the problem could be with your XML input.[/color]

      the content is located at http://blog.stocholm.dk

      When displayed in IE the result is as expected - but not in FireFox

      :-)

      --
      Jesper Stocholm


      "Man knepper ikke en anden ridders mø"

      Comment

      • Martin Honnen

        #4
        Re: Xml+XSL: Problems with FireFox displaying



        Jesper Stocholm wrote:[color=blue]
        > On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
        >
        >[color=green]
        >>Jesper Stocholm wrote:[/color]
        >
        >[color=green][color=darkred]
        >>>What am I doing wrong?[/color]
        >>
        >>Hard to tell, maybe you can post the URLs of a short XML sample and XSLT
        >>demonstrati ng the problem. I see nothing wrong in that XSLT snippet you
        >>have above but the problem could be with your XML input.[/color]
        >
        >
        > the content is located at http://blog.stocholm.dk
        >
        > When displayed in IE the result is as expected - but not in FireFox[/color]

        You are transforming to XHTML but inside that template you call the
        <br/> elements are in the null namespace so make that

        <xsl:template name="break">
        <xsl:param name="text" select="."/>
        <xsl:choose>
        <xsl:when test="contains( $text, '&#xa;')">

        <xsl:value-of select="substri ng-before($text, '&#xa;')"/>
        <br xmlns="http://www.w3.org/1999/xhtml" />
        <xsl:call-template name="break">
        <xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
        </xsl:call-template>
        </xsl:when>
        <xsl:otherwis e>
        <xsl:value-of select="$text"/>
        </xsl:otherwise>

        </xsl:choose>
        </xsl:template>

        and it should work.

        By the way, to output a DOCTYPE node you shouldn't use disable output
        escaping but rather the <xsl:output> element.

        --

        Martin Honnen

        Comment

        • Jesper Stocholm

          #5
          Re: Xml+XSL: Problems with FireFox displaying

          On Fri, 05 Nov 2004 15:03:02 +0100, Martin Honnen wrote:
          [color=blue]
          > Jesper Stocholm wrote:[color=green]
          >> On Fri, 05 Nov 2004 14:43:52 +0100, Martin Honnen wrote:
          >>
          >>[color=darkred]
          >>>Jesper Stocholm wrote:[/color]
          >>
          >>[color=darkred]
          >>>>What am I doing wrong?
          >>>
          >>>Hard to tell, maybe you can post the URLs of a short XML sample and XSLT
          >>>demonstratin g the problem. I see nothing wrong in that XSLT snippet you
          >>>have above but the problem could be with your XML input.[/color]
          >>
          >>
          >> the content is located at http://blog.stocholm.dk
          >>
          >> When displayed in IE the result is as expected - but not in FireFox[/color]
          >
          > You are transforming to XHTML but inside that template you call the
          > <br/> elements are in the null namespace so make that[/color]

          aah ... :o)

          [color=blue]
          > <xsl:template name="break">
          > <xsl:param name="text" select="."/>
          > <xsl:choose>
          > <xsl:when test="contains( $text, '&#xa;')">
          >
          > <xsl:value-of select="substri ng-before($text, '&#xa;')"/>
          > <br xmlns="http://www.w3.org/1999/xhtml" />
          > <xsl:call-template name="break">
          > <xsl:with-param name="text" select="substri ng-after($text,'&# xa;')"/>
          > </xsl:call-template>
          > </xsl:when>
          > <xsl:otherwis e>
          > <xsl:value-of select="$text"/>
          > </xsl:otherwise>
          >
          > </xsl:choose>
          > </xsl:template>
          >
          > and it should work.[/color]

          It did, thanks.

          [color=blue]
          > By the way, to output a DOCTYPE node you shouldn't use disable output
          > escaping but rather the <xsl:output> element.[/color]

          Ok - I see your point. I changed it to

          <xsl:styleshe et version="1.0"
          xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">

          <xsl:output
          doctype-public="-//W3C//DTD XHTML 1.1//EN"
          doctype-system="http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"
          encoding="ISO-8859-1"
          method="html"
          />

          And the above now also looks as intended in FireFox.

          Thanks for your help and have a nice weekend,

          :o)

          --
          Jesper Stocholm


          "Man knepper ikke en anden ridders mø"

          Comment

          • Morris M. Keesan

            #6
            Re: Xml+XSL: Problems with FireFox displaying

            On Fri, 5 Nov 2004 14:03:01 +0100, Jesper Stocholm <j@stocholm.inv alid>
            wrote:
            [color=blue]
            >And - are there some programs out there that will allow me to supply a
            >XML-file and a XSL-stylesheet - and then display the result of the
            >XSL(T)-transaformation ?[/color]

            If you have a recent version of IE, you probably have MSXML somewhere on
            your system, if you can figure out how to use it.

            Or you can use either of these two open-source XSLT processors

            Saxon: http://saxon.sourceforge.net/ (Java based)
            Xalan: http://xml.apache.org/xalan-j/ (Java version)
            or http://xml.apache.org/xalan-c/ (C++ version)

            --
            Morris M. Keesan -- keesan@alum.bu. edu

            Comment

            • John Fereira

              #7
              Re: Xml+XSL: Problems with FireFox displaying

              Jesper Stocholm <j@stocholm.inv alid> wrote in
              news:cb6a7onskl o0$.lrb5z4ddb1j k$.dlg@40tude.n et:

              [color=blue]
              > And - are there some programs out there that will allow me to supply a
              > XML-file and a XSL-stylesheet - and then display the result of the
              > XSL(T)-transaformation ?
              >[/color]

              If you're looking for something that is free. Try jEdit. I know several
              people that like Eclipse and XMLBuddy as well. XMLSpy and StyleStudio are
              both good commercial products that will perform XML/XSLT transformation.
              The Xalan package has a simple XSTL transformation example that works fine
              from a command line.


              Comment

              • Jesper Stocholm

                #8
                Re: Xml+XSL: Problems with FireFox displaying

                On Fri, 05 Nov 2004 23:15:41 GMT, Morris M. Keesan wrote:
                [color=blue]
                > On Fri, 5 Nov 2004 14:03:01 +0100, Jesper Stocholm <j@stocholm.inv alid>
                > wrote:
                >[color=green]
                >>And - are there some programs out there that will allow me to supply a
                >>XML-file and a XSL-stylesheet - and then display the result of the
                >>XSL(T)-transaformation ?[/color]
                >
                > If you have a recent version of IE, you probably have MSXML somewhere on
                > your system, if you can figure out how to use it.[/color]

                I bet I can - I have used it before, I just seem to remember a command-line
                tool I once used to test xslt-transformation.
                [color=blue]
                > Or you can use either of these two open-source XSLT processors
                >
                > Saxon: http://saxon.sourceforge.net/ (Java based)
                > Xalan: http://xml.apache.org/xalan-j/ (Java version)[/color]

                I will look at the above - or write a small test-harness in C#.

                Thanks,

                :o)

                --
                Jesper Stocholm


                "Man knepper ikke en anden ridders mø"

                Comment

                Working...