in reply to Re: Text to XML
in thread Text to XML

The XML submitted by the OP is indeed strange, but I think it's just typos. list-item and listitem should be just one, and, like you suggested, I would call it item.

Once this is fixed, the original XML is perfectly reasonable. In any case I would certainly not call it "crazy". It is standard practice to have a list contain only items, not a mixture of items and lists as you suggest at the end of your post. That's how XHTML, Docbook, and just about any other DTD out there works.

If anything the XML you propose is harder to handle with most tools. It might be easier to process with XML::Smart, but that's a (minor) gripe I have with both XML::Smart and XML::Simple: they sometimes lead to XML that is designed with the tool in mind, instead of following standard practices and proper XML design.

Replies are listed 'Best First'.
Re: Re: Re: Text to XML
by gmpassos (Priest) on Apr 13, 2004 at 08:26 UTC
    XML::Smart and XML::Simple doesn't follow any DTD to read a XML!

    What I say that is crazy, is the use of <list> in 2 ways, that I don't think that can be defined well with a DTD.

    Also you really need to take care with typos. in XML, foo-bar, is very different of foobar, that is different of FOOBAR! Soo, when I saw list-item, and listitem, for me as a XML tag, they are things different, but only similar in the name. So, the structure that I suggest in the end, is based in the same tree structure sent in the main post, where yes, it has a list with items and sub lists inside it, since I won't judge that structure, I'm only judging the use of similar names for tags and use of the same name, <list>, in different ways.

    And don't forget that without "following standard practices and proper XML design." you don't have a real XML, for the real purpose of XML, be a standart format. And without a real XML you just don't need XML, you can use better things to declare a tree.

    Good luck!

    Graciliano M. P.
    "Creativity is the expression of the liberty".

      What I say that is crazy, is the use of <list> in 2 ways, that I don't think that can be defined well with a DTD.

      Uh? What about this:

      <!ELEMENT list (listitem+)> <!ATTLIST list type (numbered|unnumbered|plain) #REQUIRED> <!ELEMENT listitem (#PCDATA|list)*>

      This describes exactly the target XML

      What you proposed would be:

      <!ELEMENT list (listitem|list)+> <!ATTLIST list type (numbered|unnumbered|plain) #REQUIRED> <!ELEMENT listitem (#PCDATA)>

      Once again this is not the usual, and recommended, way of structuring lists.

      And if you read my previous posts, I think I agree with you that the typos need to be fixed.

      Oh, and this debate is probably moot anyway, as Murugesan mentionned a DTD, that seems to be out of his control.