xml.sax removing newlines from attribute value?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Grant Edwards

    #1

    xml.sax removing newlines from attribute value?

    I'm using xml.sax to parse the "datebook" xml file generated by
    QTopiaDesktop. When I look at the xml file, some of the
    attribute strings have newlines in them (as they are supposed
    to).

    However, when xml.sax passes the attributes to my
    startElement() method the newlines seem to have been deleted.

    How do I get the un-munged element attribute values?

    --
    Grant Edwards grante Yow! Someone is DROOLING
    at on my collar!!
    visi.com
  • Fredrik Lundh

    #2
    Re: xml.sax removing newlines from attribute value?

    Grant Edwards wrote:
    [color=blue]
    > I'm using xml.sax to parse the "datebook" xml file generated by
    > QTopiaDesktop. When I look at the xml file, some of the
    > attribute strings have newlines in them (as they are supposed
    > to).
    >
    > However, when xml.sax passes the attributes to my
    > startElement() method the newlines seem to have been deleted.
    >
    > How do I get the un-munged element attribute values?[/color]

    newlines as in chr(10) rather than 
 ?

    if so, the only way is to avoid XML:



    if the "yes, I know, but I have good reasons" approach is okay with you,
    and you're big enough to defend yourself against the XML-Is-The-Law
    crowd, you can use a "sloppy" XML parsers such as sgmlop to deal with
    your files:



    </F>



    Comment

    • Grant Edwards

      #3
      Re: xml.sax removing newlines from attribute value?

      On 2005-09-29, Fredrik Lundh <fredrik@python ware.com> wrote:
      [color=blue][color=green]
      >> I'm using xml.sax to parse the "datebook" xml file generated
      >> by QTopiaDesktop. When I look at the xml file, some of the
      >> attribute strings have newlines in them (as they are supposed
      >> to).
      >>
      >> However, when xml.sax passes the attributes to my
      >> startElement() method the newlines seem to have been deleted.
      >>
      >> How do I get the un-munged element attribute values?[/color]
      >
      > newlines as in chr(10) rather than &#xa; ?[/color]

      Yup, Looks that way.
      [color=blue]
      > if so, the only way is to avoid XML:
      >
      > http://www.w3.org/TR/REC-xml/#AVNormalize[/color]

      I can't quite find it in the BNF, but I take it that chr(10)
      isn't really allowed in XML attribute strings. IOW, the file
      generate by Trolltech's app is broken.
      [color=blue]
      > if the "yes, I know, but I have good reasons" approach is okay
      > with you,[/color]

      I didn't define the file or write the program that generated
      it. It's claimed to be "xml", and I'm just trying to parse it.
      [color=blue]
      > and you're big enough to defend yourself against the
      > XML-Is-The-Law crowd, you can use a "sloppy" XML parsers such
      > as sgmlop to deal with your files:
      >
      > http://effbot.org/zone/sgmlop-index.htm[/color]

      Good to know for future reference. For now, I think I'll just
      live with the way it works. Everything basically works, except
      some strings don't display quite "right". My current app
      treats the file as read-only. If I ever get around to
      modifying data and writing it back, I'll probably have to deal
      with the newline issue at that point.

      --
      Grant Edwards grante Yow! When this load is
      at DONE I think I'll wash
      visi.com it AGAIN...

      Comment

      • Fredrik Lundh

        #4
        Re: xml.sax removing newlines from attribute value?

        Grant Edwards wrote:
        [color=blue][color=green]
        >> http://www.w3.org/TR/REC-xml/#AVNormalize[/color]
        >
        > I can't quite find it in the BNF, but I take it that chr(10)
        > isn't really allowed in XML attribute strings. IOW, the file
        > generate by Trolltech's app is broken.[/color]

        it's allowed, but the parser must not pass it on to the application.

        (in other words, whitespace in attributes doesn't, in general, survive
        roundtripping)

        </F>



        Comment

        • Grant Edwards

          #5
          Re: xml.sax removing newlines from attribute value?

          On 2005-09-29, Fredrik Lundh <fredrik@python ware.com> wrote:
          [color=blue][color=green][color=darkred]
          >>> http://www.w3.org/TR/REC-xml/#AVNormalize[/color]
          >>
          >> I can't quite find it in the BNF, but I take it that chr(10)
          >> isn't really allowed in XML attribute strings. IOW, the file
          >> generate by Trolltech's app is broken.[/color]
          >
          > it's allowed, but the parser must not pass it on to the application.
          >
          > (in other words, whitespace in attributes doesn't, in general, survive
          > roundtripping)[/color]

          Ah, I see. That's good to know.

          [This is my first attempt at anything XMLish.]

          --
          Grant Edwards grante Yow! I know how to do
          at SPECIAL EFFECTS!!
          visi.com

          Comment

          Working...