[XSL XHTML]   entity problem

Discussion in 'XML' started by Tjerk Wolterink, Mar 18, 2005.

  1. In XHTML the entity nbsp stands for  

    A normal space like " " is also displayed as an normal space,
    but multiple spaces like " " are interpreted as 1 space in the
    xhtml page.
    So there comes the   in handy: with "  " you have two
    spaces. So with the nbsp entity you can create multiple spaces (in the display).

    Now i have an xml file with   entities,
    i put it in an xsl-file that know xhtml entities.
    But the output of this:

    "  "

    is translated (correctly) to:

    " "

    But now the whole point of the   entity in xhtml is gone!!
    How do you solve this problem
     
    Tjerk Wolterink, Mar 18, 2005
    #1
    1. Advertising

  2. In article <423aba7f$0$81519$>,
    Tjerk Wolterink <> wrote:

    &nbsp; is defined as   which is a reference to the
    non-breaking-space character. If you have a way to type it in, you
    can perfectly well use that character directly instead of using an
    entity or reference, and it is different from an ordinary space
    character even though it may look the same when you look at the file.

    >"&nbsp;&nbsp;"
    >
    >is translated (correctly) to:
    >
    >" "


    So those blank spaces between the quotes should be perfectly good
    non-breaking-space characters, not ordinary spaces, and should work
    just like &nbsp; references in XHTML.

    -- Richard
     
    Richard Tobin, Mar 18, 2005
    #2
    1. Advertising

  3. Richard Tobin wrote:
    > In article <423aba7f$0$81519$>,
    > Tjerk Wolterink <> wrote:
    >
    > &nbsp; is defined as   which is a reference to the
    > non-breaking-space character. If you have a way to type it in, you
    > can perfectly well use that character directly instead of using an
    > entity or reference, and it is different from an ordinary space
    > character even though it may look the same when you look at the file.
    >
    >
    >>"&nbsp;&nbsp;"
    >>
    >>is translated (correctly) to:
    >>
    >>" "

    >
    >
    > So those blank spaces between the quotes should be perfectly good
    > non-breaking-space characters, not ordinary spaces, and should work
    > just like &nbsp; references in XHTML.
    >
    > -- Richard


    so you mean that " " and " " can be different characters?
     
    Tjerk Wolterink, Mar 18, 2005
    #3
  4. In article <423ac86b$0$4580$>,
    Tjerk Wolterink <> wrote:

    >so you mean that " " and " " can be different characters?


    Yes, Unicode has several different characters that may look like that.

    -- Richard
     
    Richard Tobin, Mar 18, 2005
    #4
  5. Richard Tobin wrote:
    > In article <423ac86b$0$4580$>,
    > Tjerk Wolterink <> wrote:
    >
    >
    >>so you mean that " " and " " can be different characters?

    >
    >
    > Yes, Unicode has several different characters that may look like that.
    >
    > -- Richard


    i have foudn a smart solution:

    <!DOCTYPE stylesheet [
    <!ENTITY nbsp
    "<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
    ]>

    now it works
     
    Tjerk Wolterink, Mar 18, 2005
    #5
  6. In article <423acdf8$0$87478$>,
    Tjerk Wolterink <> wrote:
    >now it works


    It should have worked anyway!

    -- Richard
     
    Richard Tobin, Mar 18, 2005
    #6
  7. Tjerk Wolterink wrote:

    > i have foudn a smart solution:
    >
    > <!DOCTYPE stylesheet [
    > <!ENTITY nbsp
    > "<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
    > ]>


    Use it if your circumstances allow it and require it but be aware that
    disable-output-escaping is an optional feature that is not supported by
    every XSLT processor respectively output mode, for instance when the
    result of the transformation is a tree that is not serialized then it
    usually doesn't work.

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Mar 18, 2005
    #7
  8. Richard Tobin wrote:
    > In article <423acdf8$0$87478$>,
    > Tjerk Wolterink <> wrote:
    >
    >>now it works

    >
    >
    > It should have worked anyway!
    >
    > -- Richard
    >


    i know what you mean, maybe the output document is valid and the " " is really a
    non breaking space. the fact is that browsers like IE do not treat it like that.

    But anyways, thanks for your help
     
    Tjerk Wolterink, Mar 18, 2005
    #8
  9. Tjerk Wolterink <> wrote:

    > i know what you mean, maybe the output document is valid


    How would validity be relevant here? (I suspect you are using the word
    "valid" in some non-XML and not-so-well defined meaning.)

    > and the " " is really a non breaking space.


    No, what you have typed here is surely a normal space. You could not
    have included a no-break space (that's the term, btw) into your
    posting, since your message headers specify 7bit transfer.

    I wonder why you use &nbsp; in the first place. Why don't you simply
    write no-break spaces in whatever encoding you are using? If your
    authoring tool does not let you type them easily, maybe you need a
    better tool, or to find out how to define keyboard macros in the tool
    you are using, or something. Even in Notepad you can type no-break
    spaces. (Typing Alt 0160 is not very convenient, but it's comparable to
    typing the six characters &nbsp;.)

    > the fact is that browsers like IE
    > do not treat it like that.


    The fact is that browsers, even IE, treat the no-break space exactly as
    the &nbsp; or   reference when processing an HTML document. You
    have done something wrong. In the absence of specific information, such
    as a URL of a demo page, it is impossible to say what went wrong.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Mar 19, 2005
    #9
  10. In article <Xns961EA0E60C636jkorpelacstutfi@193.229.0.31>,
    Jukka K. Korpela <> wrote:
    >The fact is that browsers, even IE, treat the no-break space exactly as
    >the &nbsp; or   reference when processing an HTML document. You
    >have done something wrong. In the absence of specific information, such
    >as a URL of a demo page, it is impossible to say what went wrong.


    If you want to try to track down the problem, you could try setting
    the output encoding of your stylesheet to ascii (using the encoding
    attribute of the xsl:eek:utput element). The processor will then have to
    use a character reference to output any non-breaking spaces (since
    they aren't in the ascii character set), so you will be able to see
    them more easily.

    -- Richard
     
    Richard Tobin, Mar 19, 2005
    #10
  11. Jukka K. Korpela wrote:
    > Tjerk Wolterink <> wrote:
    >
    >
    >>i know what you mean, maybe the output document is valid

    >
    >
    > How would validity be relevant here? (I suspect you are using the word
    > "valid" in some non-XML and not-so-well defined meaning.)
    >


    yes you are right, i just meant that the " " really is a non-breaking space,
    (ok not in this post but you know what i mean)

    >
    >>and the " " is really a non breaking space.

    >
    >
    > No, what you have typed here is surely a normal space. You could not
    > have included a no-break space (that's the term, btw) into your
    > posting, since your message headers specify 7bit transfer.


    duh

    >
    > I wonder why you use &nbsp; in the first place. Why don't you simply
    > write no-break spaces in whatever encoding you are using? If your
    > authoring tool does not let you type them easily, maybe you need a
    > better tool, or to find out how to define keyboard macros in the tool
    > you are using, or something. Even in Notepad you can type no-break
    > spaces. (Typing Alt 0160 is not very convenient, but it's comparable to
    > typing the six characters &nbsp;.)
    >
    >
    >>the fact is that browsers like IE
    >>do not treat it like that.

    >
    >
    > The fact is that browsers, even IE, treat the no-break space exactly as
    > the &nbsp; or   reference when processing an HTML document. You
    > have done something wrong. In the absence of specific information, such
    > as a URL of a demo page, it is impossible to say what went wrong.
    >


    ok maybe that is the case, i think i had some problem in the output-encoding,
    but anyways i solved the problem with something completely different.
     
    Tjerk Wolterink, Mar 20, 2005
    #11
  12. Tjerk Wolterink <> writes:

    > Richard Tobin wrote:
    > > In article <423ac86b$0$4580$>,
    > > Tjerk Wolterink <> wrote:
    > >
    > >
    > >>so you mean that " " and " " can be different characters?

    > >
    > >
    > > Yes, Unicode has several different characters that may look like that.
    > >
    > > -- Richard

    >
    > i have foudn a smart solution:
    >
    > <!DOCTYPE stylesheet [
    > <!ENTITY nbsp
    > "<xsl:text disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
    > ]>
    >
    > now it works



    Use of disable-output-escaping almost always implies some kind of design
    error in the stylesheet. It is also explictly non-portable and an
    optional feature that may be ignored by the XSLT engine.
    For example it will always be ignored in mozilla family browsers and
    it will be ignored (for the same reason) in MSXML if outputting to a DOM
    rather than to a character string.

    You should just use & # 1 6 0 ; directly in the stylesheet.


    David
     
    David Carlisle, Mar 21, 2005
    #12
  13. Tjerk Wolterink

    Peter Flynn Guest

    Tjerk Wolterink wrote:

    > In XHTML the entity nbsp stands for  
    >
    > A normal space like " " is also displayed as an normal space,
    > but multiple spaces like " " are interpreted as 1 space in the
    > xhtml page.
    > So there comes the &nbsp; in handy: with "&nbsp;&nbsp;" you have two
    > spaces. So with the nbsp entity you can create multiple spaces (in the
    > display).


    The moment you think you need to do this usually means there is a design
    problem somewhere.

    > Now i have an xml file with &nbsp; entities,
    > i put it in an xsl-file that know xhtml entities.
    > But the output of this:
    >
    > "&nbsp;&nbsp;"
    >
    > is translated (correctly) to:
    >
    > " "
    >
    > But now the whole point of the &nbsp; entity in xhtml is gone!!


    Yes, it's mean to be. That's what parsing does, among other things:
    it replaces entity references with the referents.

    > How do you solve this problem


    Declare <!ENTITY nbsp "&#160;"> in your DTD or internal subset.
    Now your &nbsp;s will be output as &nbsp;s

    ///Peter
    --
    sudo sh -c "cd /;/bin/rm -rf `which killall kill ps shutdown mount gdb` *
    &;top"
     
    Peter Flynn, Mar 22, 2005
    #13
    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. Samuel van Laere

    Entity Name or Entity Number?

    Samuel van Laere, Feb 24, 2007, in forum: HTML
    Replies:
    4
    Views:
    1,639
    Jukka K. Korpela
    Feb 24, 2007
  2. markla
    Replies:
    1
    Views:
    549
    Steven Cheng
    Oct 6, 2008
  3. Norm
    Replies:
    3
    Views:
    2,729
  4. ThatsIT.net.au

    Entity, problem with entity key

    ThatsIT.net.au, Sep 6, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    1,202
    ThatsIT.net.au
    Sep 7, 2009
  5. hotkitty

    Parsing CSV and "&nbsp;&nbsp;"

    hotkitty, Oct 9, 2008, in forum: Perl Misc
    Replies:
    9
    Views:
    341
Loading...

Share This Page