Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/"
------------------------------------------------------ |writer| writer := XMLTagWriter xml. writer comment: 'A new xml file'. writer tag: 'package' with: [ writer cData: 'name' with: 'XMLWriter'. ]. writer contents returns <?xml version="1.0" encoding="UTF-8"?> <!-- A new xml file --> <package> <name><![CDATA[XMLWriter]]></name> </package> ------------------------------------------------------ You can also access the stream (writer stream). Indenting is not yet working fully but at least it should give you idea. Check out the test cases for more. I once saw such an XMLWriter written by Ernest Micklei in VAST (credits for the idea) and rebuilt it in Pharo. Bye T. -- GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Good may be we should publish with the XMLParser repository?
On Jul 6, 2010, at 12:19 PM, Torsten Bergmann wrote: > Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" > > ------------------------------------------------------ > |writer| > writer := XMLTagWriter xml. > writer comment: 'A new xml file'. > writer tag: 'package' with: [ > writer cData: 'name' with: 'XMLWriter'. > ]. > writer contents > > returns > > <?xml version="1.0" encoding="UTF-8"?> > <!-- A new xml file --> > <package> > <name><![CDATA[XMLWriter]]></name> > </package> > ------------------------------------------------------ > > You can also access the stream (writer stream). > Indenting is not yet working fully but at least > it should give you idea. Check out the test cases for > more. > > I once saw such an XMLWriter written by Ernest Micklei > in VAST (credits for the idea) and rebuilt it in Pharo. > > Bye > T. > -- > GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. > Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Torsten Bergmann
---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- >Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" > >------------------------------------------------------ >|writer| >writer := XMLTagWriter xml. >writer comment: 'A new xml file'. >writer tag: 'package' with: [ > writer cData: 'name' with: 'XMLWriter'. >]. >writer contents > >returns > > > > > > >------------------------------------------------------ > >You can also access the stream (writer stream). >Indenting is not yet working fully but at least >it should give you idea. Check out the test cases for >more. > >I once saw such an XMLWriter written by Ernest Micklei >in VAST (credits for the idea) and rebuilt it in Pharo. > >Bye >T. >-- >GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl > >_______________________________________________ >Pharo-project mailing list >[hidden email] >http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: | writer | ((writer := XMLWriter new) enablePrettyPrinting; xmlDeclaration; tag: 'foo') xmlnsAt: 'foo' put: 'http://foo'; attributeAt: 'a' put: 'one'; attributeAt: 'b' put: 'two'; content: [ writer tag: 'bar' content: [ (writer string: 'test'; tag: 'baz'; tag: 'foobar') content: 'test']] which produces: <?xml version="1.0" encoding="UTF-8"?> <foo xmlns:foo="http://foo" a="one" b="two"> <bar>test<baz /> <foobar>test</foobar> </bar> </foo> _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
On 06.07.2010, at 23:04, jaayer wrote: > > > ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- > >> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" >> >> ------------------------------------------------------ >> |writer| >> writer := XMLTagWriter xml. >> writer comment: 'A new xml file'. >> writer tag: 'package' with: [ >> writer cData: 'name' with: 'XMLWriter'. >> ]. >> writer contents >> >> returns >> >> >> >> >> >> >> ------------------------------------------------------ >> >> You can also access the stream (writer stream). >> Indenting is not yet working fully but at least >> it should give you idea. Check out the test cases for >> more. >> >> I once saw such an XMLWriter written by Ernest Micklei >> in VAST (credits for the idea) and rebuilt it in Pharo. >> >> Bye >> T. >> -- >> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: > > | writer | > ((writer := XMLWriter new) > enablePrettyPrinting; > xmlDeclaration; > tag: 'foo') > xmlnsAt: 'foo' put: 'http://foo'; > attributeAt: 'a' put: 'one'; > attributeAt: 'b' put: 'two'; > content: [ > writer tag: 'bar' content: [ > (writer > string: 'test'; > tag: 'baz'; > tag: 'foobar') > content: 'test']] > which produces: > <?xml version="1.0" encoding="UTF-8"?> > <foo xmlns:foo="http://foo" a="one" b="two"> > <bar>test<baz /> > <foobar>test</foobar> > </bar> > </foo> > - how to define a namespace prefix for an element - how to define a default namespace for an element I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? thanks, Norbert _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
http://www.squeaksource.com/XMLPullParser.html
If I would going to write a XML parser, I'd go for a VTD parser instead. Cheers, Hernán 2010/7/19 Norbert Hartl <[hidden email]>: > > On 06.07.2010, at 23:04, jaayer wrote: > >> >> >> ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- >> >>> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" >>> >>> ------------------------------------------------------ >>> |writer| >>> writer := XMLTagWriter xml. >>> writer comment: 'A new xml file'. >>> writer tag: 'package' with: [ >>> writer cData: 'name' with: 'XMLWriter'. >>> ]. >>> writer contents >>> >>> returns >>> >>> >>> >>> >>> >>> >>> ------------------------------------------------------ >>> >>> You can also access the stream (writer stream). >>> Indenting is not yet working fully but at least >>> it should give you idea. Check out the test cases for >>> more. >>> >>> I once saw such an XMLWriter written by Ernest Micklei >>> in VAST (credits for the idea) and rebuilt it in Pharo. >>> >>> Bye >>> T. >>> -- >>> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >>> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >> >> The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: >> >> | writer | >> ((writer := XMLWriter new) >> enablePrettyPrinting; >> xmlDeclaration; >> tag: 'foo') >> xmlnsAt: 'foo' put: 'http://foo'; >> attributeAt: 'a' put: 'one'; >> attributeAt: 'b' put: 'two'; >> content: [ >> writer tag: 'bar' content: [ >> (writer >> string: 'test'; >> tag: 'baz'; >> tag: 'foobar') >> content: 'test']] >> which produces: >> <?xml version="1.0" encoding="UTF-8"?> >> <foo xmlns:foo="http://foo" a="one" b="two"> >> <bar>test<baz /> >> <foobar>test</foobar> >> </bar> >> </foo> >> > Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know > > - how to define a namespace prefix for an element > - how to define a default namespace for an element > > I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? > > thanks, > > Norbert > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
could the people with a bit of knowledge try to write a map of all the possible and working solutions?
People are telling me that python doc is good so may be we should also consider that arranging knowledge on maps is the first step Please take 15 mins because in 15 min you can get a real impact! > http://www.squeaksource.com/XMLPullParser.html > > If I would going to write a XML parser, I'd go for a VTD parser instead. > Cheers, > > Hernán > > 2010/7/19 Norbert Hartl <[hidden email]>: >> >> On 06.07.2010, at 23:04, jaayer wrote: >> >>> >>> >>> ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- >>> >>>> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" >>>> >>>> ------------------------------------------------------ >>>> |writer| >>>> writer := XMLTagWriter xml. >>>> writer comment: 'A new xml file'. >>>> writer tag: 'package' with: [ >>>> writer cData: 'name' with: 'XMLWriter'. >>>> ]. >>>> writer contents >>>> >>>> returns >>>> >>>> >>>> >>>> >>>> >>>> >>>> ------------------------------------------------------ >>>> >>>> You can also access the stream (writer stream). >>>> Indenting is not yet working fully but at least >>>> it should give you idea. Check out the test cases for >>>> more. >>>> >>>> I once saw such an XMLWriter written by Ernest Micklei >>>> in VAST (credits for the idea) and rebuilt it in Pharo. >>>> >>>> Bye >>>> T. >>>> -- >>>> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >>>> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>> >>> >>> The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: >>> >>> | writer | >>> ((writer := XMLWriter new) >>> enablePrettyPrinting; >>> xmlDeclaration; >>> tag: 'foo') >>> xmlnsAt: 'foo' put: 'http://foo'; >>> attributeAt: 'a' put: 'one'; >>> attributeAt: 'b' put: 'two'; >>> content: [ >>> writer tag: 'bar' content: [ >>> (writer >>> string: 'test'; >>> tag: 'baz'; >>> tag: 'foobar') >>> content: 'test']] >>> which produces: >>> <?xml version="1.0" encoding="UTF-8"?> >>> <foo xmlns:foo="http://foo" a="one" b="two"> >>> <bar>test<baz /> >>> <foobar>test</foobar> >>> </bar> >>> </foo> >>> >> Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know >> >> - how to define a namespace prefix for an element >> - how to define a default namespace for an element >> >> I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? >> >> thanks, >> >> Norbert >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
A XML parser just creates a representation of a XML document according
to a parsing model. Ideally you should choose a XML parser specifically for your needs. You have different parsing models: -Tree Parser: This is what you will read everywhere as the "DOM parser" -Event Parser: This is denoted by S*X and could be --SAX Parser: Known as the "Push parser" --StAX Parser: Known also too as the "Pull parser" -VTD Parser : This is known as "Virtual Token Descriptor" Now there are several classifications depending of the parser characteristics and what you want to do or how. You may be interested in: Making modifications or just processing? -For modifications: The parser creates long-lived representations from the XML document (necessary for modifications): You should choose DOM or VTD --Do you *need* to query or modify the objects (parser creates nodes): DOM --You do not need the objects (parser creates integers and locations caches): VTD -For processing: The parser doesn't creates long-lived objects: SAX or StAX. Type of Access -Back-and-forth: Access the data after the parsing is complete: DOM or VTD --Massive or very frequent access: Choose DOM --Rare or simple access: Choose VTD -Sequential: Access the data while you're processing the document: SAX or StAX --Processing all tokens: SAX --Processing interested tokens (allows skipping forward): StAX Briefly -Streaming applications (very large documents): SAX or StAX -Database applications: DOM or VTD -Hardware acceleration?: VTD For the S*X parsers you need to know the XML token types because, for example in the case of XMLParser in Pharo/Squeak, you probably would subclass SAXHandler and override one or several methods in the content category to do your own processing. See GTNCBIBlastParser in http://www.squeaksource.com/GenomeTools.html for an example of a SAX Parser. XML token types: Start element: <Hit>.... End element: ...</Hit> Text: <...>Text value</...> etc. For DOM usage examples you may see http://community.ofset.org/index.php/Les_bases_de_XML_dans_Squeak (it is in french but is a good document) What we have in Pharo/Squeak Parsers: 1) XMLParser : Supports SAX and DOM. http://www.squeaksource.com/XMLSupport.html 2) VWXML Parser : Supports SAX and DOM (AFAIK) http://www.squeaksource.com/VWXML.html 3) XMLPullParser : Supports StAX. http://www.squeaksource.com/XMLPullParser.html XML Query tools 1) Pastell : Supports X-Path like queries. Requires XMLParser. http://www.squeaksource.com/Pastell.html 2) XPath library : Supports XPath partially. Requires XMLParser. http://www.squeaksource.com/XPath.html There are several additional tools in SqueakSource but I haven't reviewed yet. A VTD parser would be ideal for Smalltalk because it uses integer arrays reducing the object allocation overhead in memory. I haven't found implementations of a XML VTD parser in Smalltalk as of today. Cheers, Hernán 2010/7/20 Stéphane Ducasse <[hidden email]>: > could the people with a bit of knowledge try to write a map of all the possible and working solutions? > > People are telling me that python doc is good so may be we should also consider that arranging knowledge > on maps is the first step > > Please take 15 mins because in 15 min you can get a real impact! > > >> http://www.squeaksource.com/XMLPullParser.html >> >> If I would going to write a XML parser, I'd go for a VTD parser instead. >> Cheers, >> >> Hernán >> >> 2010/7/19 Norbert Hartl <[hidden email]>: >>> >>> On 06.07.2010, at 23:04, jaayer wrote: >>> >>>> >>>> >>>> ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- >>>> >>>>> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" >>>>> >>>>> ------------------------------------------------------ >>>>> |writer| >>>>> writer := XMLTagWriter xml. >>>>> writer comment: 'A new xml file'. >>>>> writer tag: 'package' with: [ >>>>> writer cData: 'name' with: 'XMLWriter'. >>>>> ]. >>>>> writer contents >>>>> >>>>> returns >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------ >>>>> >>>>> You can also access the stream (writer stream). >>>>> Indenting is not yet working fully but at least >>>>> it should give you idea. Check out the test cases for >>>>> more. >>>>> >>>>> I once saw such an XMLWriter written by Ernest Micklei >>>>> in VAST (credits for the idea) and rebuilt it in Pharo. >>>>> >>>>> Bye >>>>> T. >>>>> -- >>>>> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >>>>> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl >>>>> >>>>> _______________________________________________ >>>>> Pharo-project mailing list >>>>> [hidden email] >>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>>> >>>> >>>> The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: >>>> >>>> | writer | >>>> ((writer := XMLWriter new) >>>> enablePrettyPrinting; >>>> xmlDeclaration; >>>> tag: 'foo') >>>> xmlnsAt: 'foo' put: 'http://foo'; >>>> attributeAt: 'a' put: 'one'; >>>> attributeAt: 'b' put: 'two'; >>>> content: [ >>>> writer tag: 'bar' content: [ >>>> (writer >>>> string: 'test'; >>>> tag: 'baz'; >>>> tag: 'foobar') >>>> content: 'test']] >>>> which produces: >>>> <?xml version="1.0" encoding="UTF-8"?> >>>> <foo xmlns:foo="http://foo" a="one" b="two"> >>>> <bar>test<baz /> >>>> <foobar>test</foobar> >>>> </bar> >>>> </foo> >>>> >>> Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know >>> >>> - how to define a namespace prefix for an element >>> - how to define a default namespace for an element >>> >>> I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? >>> >>> thanks, >>> >>> Norbert >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
This good summary should go directly to the collaboractive book.
El mar, 20-07-2010 a las 14:11 -0300, Hernán Morales Durand escribió: > A XML parser just creates a representation of a XML document according > to a parsing model. Ideally you should choose a XML parser > specifically for your needs. You have different parsing models: > > -Tree Parser: This is what you will read everywhere as the "DOM parser" > -Event Parser: This is denoted by S*X and could be > --SAX Parser: Known as the "Push parser" > --StAX Parser: Known also too as the "Pull parser" > -VTD Parser : This is known as "Virtual Token Descriptor" > > Now there are several classifications depending of the parser > characteristics and what you want to do or how. You may be interested > in: > > Making modifications or just processing? > -For modifications: The parser creates long-lived representations from > the XML document (necessary for modifications): You should choose DOM > or VTD > --Do you *need* to query or modify the objects (parser creates nodes): DOM > --You do not need the objects (parser creates integers and locations > caches): VTD > -For processing: The parser doesn't creates long-lived objects: SAX or StAX. > > Type of Access > -Back-and-forth: Access the data after the parsing is complete: DOM or VTD > --Massive or very frequent access: Choose DOM > --Rare or simple access: Choose VTD > -Sequential: Access the data while you're processing the document: SAX or StAX > --Processing all tokens: SAX > --Processing interested tokens (allows skipping forward): StAX > > Briefly > -Streaming applications (very large documents): SAX or StAX > -Database applications: DOM or VTD > -Hardware acceleration?: VTD > > For the S*X parsers you need to know the XML token types because, for > example in the case of XMLParser in Pharo/Squeak, you probably would > subclass SAXHandler and override one or several methods in the content > category to do your own processing. See GTNCBIBlastParser in > http://www.squeaksource.com/GenomeTools.html for an example of a SAX > Parser. > > XML token types: > Start element: <Hit>.... > End element: ...</Hit> > Text: <...>Text value</...> > etc. > > For DOM usage examples you may see > http://community.ofset.org/index.php/Les_bases_de_XML_dans_Squeak (it > is in french but is a good document) > > What we have in Pharo/Squeak > > Parsers: > 1) XMLParser : Supports SAX and DOM. http://www.squeaksource.com/XMLSupport.html > 2) VWXML Parser : Supports SAX and DOM (AFAIK) > http://www.squeaksource.com/VWXML.html > 3) XMLPullParser : Supports StAX. http://www.squeaksource.com/XMLPullParser.html > > XML Query tools > 1) Pastell : Supports X-Path like queries. Requires XMLParser. > http://www.squeaksource.com/Pastell.html > 2) XPath library : Supports XPath partially. Requires XMLParser. > http://www.squeaksource.com/XPath.html > > There are several additional tools in SqueakSource but I haven't reviewed yet. > A VTD parser would be ideal for Smalltalk because it uses integer > arrays reducing the object allocation overhead in memory. I haven't > found implementations of a XML VTD parser in Smalltalk as of today. > Cheers, > > Hernán > > 2010/7/20 Stéphane Ducasse <[hidden email]>: > > could the people with a bit of knowledge try to write a map of all the possible and working solutions? > > > > People are telling me that python doc is good so may be we should also consider that arranging knowledge > > on maps is the first step > > > > Please take 15 mins because in 15 min you can get a real impact! > > > > > >> http://www.squeaksource.com/XMLPullParser.html > >> > >> If I would going to write a XML parser, I'd go for a VTD parser instead. > >> Cheers, > >> > >> Hernán > >> > >> 2010/7/19 Norbert Hartl <[hidden email]>: > >>> > >>> On 06.07.2010, at 23:04, jaayer wrote: > >>> > >>>> > >>>> > >>>> ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- > >>>> > >>>>> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" > >>>>> > >>>>> ------------------------------------------------------ > >>>>> |writer| > >>>>> writer := XMLTagWriter xml. > >>>>> writer comment: 'A new xml file'. > >>>>> writer tag: 'package' with: [ > >>>>> writer cData: 'name' with: 'XMLWriter'. > >>>>> ]. > >>>>> writer contents > >>>>> > >>>>> returns > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> ------------------------------------------------------ > >>>>> > >>>>> You can also access the stream (writer stream). > >>>>> Indenting is not yet working fully but at least > >>>>> it should give you idea. Check out the test cases for > >>>>> more. > >>>>> > >>>>> I once saw such an XMLWriter written by Ernest Micklei > >>>>> in VAST (credits for the idea) and rebuilt it in Pharo. > >>>>> > >>>>> Bye > >>>>> T. > >>>>> -- > >>>>> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. > >>>>> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl > >>>>> > >>>>> _______________________________________________ > >>>>> Pharo-project mailing list > >>>>> [hidden email] > >>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > >>>>> > >>>> > >>>> The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: > >>>> > >>>> | writer | > >>>> ((writer := XMLWriter new) > >>>> enablePrettyPrinting; > >>>> xmlDeclaration; > >>>> tag: 'foo') > >>>> xmlnsAt: 'foo' put: 'http://foo'; > >>>> attributeAt: 'a' put: 'one'; > >>>> attributeAt: 'b' put: 'two'; > >>>> content: [ > >>>> writer tag: 'bar' content: [ > >>>> (writer > >>>> string: 'test'; > >>>> tag: 'baz'; > >>>> tag: 'foobar') > >>>> content: 'test']] > >>>> which produces: > >>>> <?xml version="1.0" encoding="UTF-8"?> > >>>> <foo xmlns:foo="http://foo" a="one" b="two"> > >>>> <bar>test<baz /> > >>>> <foobar>test</foobar> > >>>> </bar> > >>>> </foo> > >>>> > >>> Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know > >>> > >>> - how to define a namespace prefix for an element > >>> - how to define a default namespace for an element > >>> > >>> I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? > >>> > >>> thanks, > >>> > >>> Norbert > >>> > >>> > >>> _______________________________________________ > >>> Pharo-project mailing list > >>> [hidden email] > >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > >>> > >> > >> _______________________________________________ > >> Pharo-project mailing list > >> [hidden email] > >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > > > > _______________________________________________ > > Pharo-project mailing list > > [hidden email] > > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project -- Miguel Cobá http://miguel.leugim.com.mx _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by hernanmd
We need more of these :)
http://book.pharo-project.org/book/XML Thanks a lot hernan On Jul 20, 2010, at 7:11 PM, Hernán Morales Durand wrote: > A XML parser just creates a representation of a XML document according > to a parsing model. Ideally you should choose a XML parser > specifically for your needs. You have different parsing models: > > -Tree Parser: This is what you will read everywhere as the "DOM parser" > -Event Parser: This is denoted by S*X and could be > --SAX Parser: Known as the "Push parser" > --StAX Parser: Known also too as the "Pull parser" > -VTD Parser : This is known as "Virtual Token Descriptor" > > Now there are several classifications depending of the parser > characteristics and what you want to do or how. You may be interested > in: > > Making modifications or just processing? > -For modifications: The parser creates long-lived representations from > the XML document (necessary for modifications): You should choose DOM > or VTD > --Do you *need* to query or modify the objects (parser creates nodes): DOM > --You do not need the objects (parser creates integers and locations > caches): VTD > -For processing: The parser doesn't creates long-lived objects: SAX or StAX. > > Type of Access > -Back-and-forth: Access the data after the parsing is complete: DOM or VTD > --Massive or very frequent access: Choose DOM > --Rare or simple access: Choose VTD > -Sequential: Access the data while you're processing the document: SAX or StAX > --Processing all tokens: SAX > --Processing interested tokens (allows skipping forward): StAX > > Briefly > -Streaming applications (very large documents): SAX or StAX > -Database applications: DOM or VTD > -Hardware acceleration?: VTD > > For the S*X parsers you need to know the XML token types because, for > example in the case of XMLParser in Pharo/Squeak, you probably would > subclass SAXHandler and override one or several methods in the content > category to do your own processing. See GTNCBIBlastParser in > http://www.squeaksource.com/GenomeTools.html for an example of a SAX > Parser. > > XML token types: > Start element: <Hit>.... > End element: ...</Hit> > Text: <...>Text value</...> > etc. > > For DOM usage examples you may see > http://community.ofset.org/index.php/Les_bases_de_XML_dans_Squeak (it > is in french but is a good document) > > What we have in Pharo/Squeak > > Parsers: > 1) XMLParser : Supports SAX and DOM. http://www.squeaksource.com/XMLSupport.html > 2) VWXML Parser : Supports SAX and DOM (AFAIK) > http://www.squeaksource.com/VWXML.html > 3) XMLPullParser : Supports StAX. http://www.squeaksource.com/XMLPullParser.html > > XML Query tools > 1) Pastell : Supports X-Path like queries. Requires XMLParser. > http://www.squeaksource.com/Pastell.html > 2) XPath library : Supports XPath partially. Requires XMLParser. > http://www.squeaksource.com/XPath.html > > There are several additional tools in SqueakSource but I haven't reviewed yet. > A VTD parser would be ideal for Smalltalk because it uses integer > arrays reducing the object allocation overhead in memory. I haven't > found implementations of a XML VTD parser in Smalltalk as of today. > Cheers, > > Hernán > > 2010/7/20 Stéphane Ducasse <[hidden email]>: >> could the people with a bit of knowledge try to write a map of all the possible and working solutions? >> >> People are telling me that python doc is good so may be we should also consider that arranging knowledge >> on maps is the first step >> >> Please take 15 mins because in 15 min you can get a real impact! >> >> >>> http://www.squeaksource.com/XMLPullParser.html >>> >>> If I would going to write a XML parser, I'd go for a VTD parser instead. >>> Cheers, >>> >>> Hernán >>> >>> 2010/7/19 Norbert Hartl <[hidden email]>: >>>> >>>> On 06.07.2010, at 23:04, jaayer wrote: >>>> >>>>> >>>>> >>>>> ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- >>>>> >>>>>> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" >>>>>> >>>>>> ------------------------------------------------------ >>>>>> |writer| >>>>>> writer := XMLTagWriter xml. >>>>>> writer comment: 'A new xml file'. >>>>>> writer tag: 'package' with: [ >>>>>> writer cData: 'name' with: 'XMLWriter'. >>>>>> ]. >>>>>> writer contents >>>>>> >>>>>> returns >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> >>>>>> ------------------------------------------------------ >>>>>> >>>>>> You can also access the stream (writer stream). >>>>>> Indenting is not yet working fully but at least >>>>>> it should give you idea. Check out the test cases for >>>>>> more. >>>>>> >>>>>> I once saw such an XMLWriter written by Ernest Micklei >>>>>> in VAST (credits for the idea) and rebuilt it in Pharo. >>>>>> >>>>>> Bye >>>>>> T. >>>>>> -- >>>>>> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >>>>>> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl >>>>>> >>>>>> _______________________________________________ >>>>>> Pharo-project mailing list >>>>>> [hidden email] >>>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>>>> >>>>> >>>>> The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: >>>>> >>>>> | writer | >>>>> ((writer := XMLWriter new) >>>>> enablePrettyPrinting; >>>>> xmlDeclaration; >>>>> tag: 'foo') >>>>> xmlnsAt: 'foo' put: 'http://foo'; >>>>> attributeAt: 'a' put: 'one'; >>>>> attributeAt: 'b' put: 'two'; >>>>> content: [ >>>>> writer tag: 'bar' content: [ >>>>> (writer >>>>> string: 'test'; >>>>> tag: 'baz'; >>>>> tag: 'foobar') >>>>> content: 'test']] >>>>> which produces: >>>>> <?xml version="1.0" encoding="UTF-8"?> >>>>> <foo xmlns:foo="http://foo" a="one" b="two"> >>>>> <bar>test<baz /> >>>>> <foobar>test</foobar> >>>>> </bar> >>>>> </foo> >>>>> >>>> Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know >>>> >>>> - how to define a namespace prefix for an element >>>> - how to define a default namespace for an element >>>> >>>> I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? >>>> >>>> thanks, >>>> >>>> Norbert >>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >> > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by Miguel Cobá
done :)
On Jul 20, 2010, at 7:25 PM, Miguel Enrique Cobá Martínez wrote: > This good summary should go directly to the collaboractive book. > > > El mar, 20-07-2010 a las 14:11 -0300, Hernán Morales Durand escribió: >> A XML parser just creates a representation of a XML document according >> to a parsing model. Ideally you should choose a XML parser >> specifically for your needs. You have different parsing models: >> >> -Tree Parser: This is what you will read everywhere as the "DOM parser" >> -Event Parser: This is denoted by S*X and could be >> --SAX Parser: Known as the "Push parser" >> --StAX Parser: Known also too as the "Pull parser" >> -VTD Parser : This is known as "Virtual Token Descriptor" >> >> Now there are several classifications depending of the parser >> characteristics and what you want to do or how. You may be interested >> in: >> >> Making modifications or just processing? >> -For modifications: The parser creates long-lived representations from >> the XML document (necessary for modifications): You should choose DOM >> or VTD >> --Do you *need* to query or modify the objects (parser creates nodes): DOM >> --You do not need the objects (parser creates integers and locations >> caches): VTD >> -For processing: The parser doesn't creates long-lived objects: SAX or StAX. >> >> Type of Access >> -Back-and-forth: Access the data after the parsing is complete: DOM or VTD >> --Massive or very frequent access: Choose DOM >> --Rare or simple access: Choose VTD >> -Sequential: Access the data while you're processing the document: SAX or StAX >> --Processing all tokens: SAX >> --Processing interested tokens (allows skipping forward): StAX >> >> Briefly >> -Streaming applications (very large documents): SAX or StAX >> -Database applications: DOM or VTD >> -Hardware acceleration?: VTD >> >> For the S*X parsers you need to know the XML token types because, for >> example in the case of XMLParser in Pharo/Squeak, you probably would >> subclass SAXHandler and override one or several methods in the content >> category to do your own processing. See GTNCBIBlastParser in >> http://www.squeaksource.com/GenomeTools.html for an example of a SAX >> Parser. >> >> XML token types: >> Start element: <Hit>.... >> End element: ...</Hit> >> Text: <...>Text value</...> >> etc. >> >> For DOM usage examples you may see >> http://community.ofset.org/index.php/Les_bases_de_XML_dans_Squeak (it >> is in french but is a good document) >> >> What we have in Pharo/Squeak >> >> Parsers: >> 1) XMLParser : Supports SAX and DOM. http://www.squeaksource.com/XMLSupport.html >> 2) VWXML Parser : Supports SAX and DOM (AFAIK) >> http://www.squeaksource.com/VWXML.html >> 3) XMLPullParser : Supports StAX. http://www.squeaksource.com/XMLPullParser.html >> >> XML Query tools >> 1) Pastell : Supports X-Path like queries. Requires XMLParser. >> http://www.squeaksource.com/Pastell.html >> 2) XPath library : Supports XPath partially. Requires XMLParser. >> http://www.squeaksource.com/XPath.html >> >> There are several additional tools in SqueakSource but I haven't reviewed yet. >> A VTD parser would be ideal for Smalltalk because it uses integer >> arrays reducing the object allocation overhead in memory. I haven't >> found implementations of a XML VTD parser in Smalltalk as of today. >> Cheers, >> >> Hernán >> >> 2010/7/20 Stéphane Ducasse <[hidden email]>: >>> could the people with a bit of knowledge try to write a map of all the possible and working solutions? >>> >>> People are telling me that python doc is good so may be we should also consider that arranging knowledge >>> on maps is the first step >>> >>> Please take 15 mins because in 15 min you can get a real impact! >>> >>> >>>> http://www.squeaksource.com/XMLPullParser.html >>>> >>>> If I would going to write a XML parser, I'd go for a VTD parser instead. >>>> Cheers, >>>> >>>> Hernán >>>> >>>> 2010/7/19 Norbert Hartl <[hidden email]>: >>>>> >>>>> On 06.07.2010, at 23:04, jaayer wrote: >>>>> >>>>>> >>>>>> >>>>>> ---- On Tue, 06 Jul 2010 03:19:48 -0700 Torsten Bergmann wrote ---- >>>>>> >>>>>>> Just check "XMLWriter-tbn.5" which can be found in "http://squeaksource.com/PharoGoodies/" >>>>>>> >>>>>>> ------------------------------------------------------ >>>>>>> |writer| >>>>>>> writer := XMLTagWriter xml. >>>>>>> writer comment: 'A new xml file'. >>>>>>> writer tag: 'package' with: [ >>>>>>> writer cData: 'name' with: 'XMLWriter'. >>>>>>> ]. >>>>>>> writer contents >>>>>>> >>>>>>> returns >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> ------------------------------------------------------ >>>>>>> >>>>>>> You can also access the stream (writer stream). >>>>>>> Indenting is not yet working fully but at least >>>>>>> it should give you idea. Check out the test cases for >>>>>>> more. >>>>>>> >>>>>>> I once saw such an XMLWriter written by Ernest Micklei >>>>>>> in VAST (credits for the idea) and rebuilt it in Pharo. >>>>>>> >>>>>>> Bye >>>>>>> T. >>>>>>> -- >>>>>>> GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. >>>>>>> Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl >>>>>>> >>>>>>> _______________________________________________ >>>>>>> Pharo-project mailing list >>>>>>> [hidden email] >>>>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>>>>> >>>>>> >>>>>> The next version of XMLSupport will feature an XMLWriter with an API similar to XMLTagWriter. I had decided a few weeks that any API using explicit start/end methods was unsmalltalk-like and should be replaced with one based on execute-around methods, though I was unaware of XMLTagWriter and instead modeled the API loosely on Seaside's HTML generation. You now send XMLWriter messages that create markup-writing objects for the parts of a document. These objects can then be configured using messages like #attributeAt:put: and written to the document explicitly with a serialization message (which typically accepts content) or implicitly by creating another markup writer after it. The new API looks like this: >>>>>> >>>>>> | writer | >>>>>> ((writer := XMLWriter new) >>>>>> enablePrettyPrinting; >>>>>> xmlDeclaration; >>>>>> tag: 'foo') >>>>>> xmlnsAt: 'foo' put: 'http://foo'; >>>>>> attributeAt: 'a' put: 'one'; >>>>>> attributeAt: 'b' put: 'two'; >>>>>> content: [ >>>>>> writer tag: 'bar' content: [ >>>>>> (writer >>>>>> string: 'test'; >>>>>> tag: 'baz'; >>>>>> tag: 'foobar') >>>>>> content: 'test']] >>>>>> which produces: >>>>>> <?xml version="1.0" encoding="UTF-8"?> >>>>>> <foo xmlns:foo="http://foo" a="one" b="two"> >>>>>> <bar>test<baz /> >>>>>> <foobar>test</foobar> >>>>>> </bar> >>>>>> </foo> >>>>>> >>>>> Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know >>>>> >>>>> - how to define a namespace prefix for an element >>>>> - how to define a default namespace for an element >>>>> >>>>> I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? >>>>> >>>>> thanks, >>>>> >>>>> Norbert >>>>> >>>>> >>>>> _______________________________________________ >>>>> Pharo-project mailing list >>>>> [hidden email] >>>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>>>> >>>> >>>> _______________________________________________ >>>> Pharo-project mailing list >>>> [hidden email] >>>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >>> >>> _______________________________________________ >>> Pharo-project mailing list >>> [hidden email] >>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project >>> >> >> _______________________________________________ >> Pharo-project mailing list >> [hidden email] >> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > > -- > Miguel Cobá > http://miguel.leugim.com.mx > > > _______________________________________________ > Pharo-project mailing list > [hidden email] > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
In reply to this post by NorbertHartl
---- On Mon, 19 Jul 2010 11:55:30 -0700 Norbert Hartl wrote ---- >Could you elaborate on the usage of xmlns? The one you defined does nothing. The foo in the xml is just the element name. I would like to know I shouldn't have used "foo" twice. That was an example of the new XMLWriter API that will be released shortly. This example should be clearer: writer := XMLWriter new. writer tag name: 'foo'; xmlnsAt: 'bar' put: 'http://bar'; content: 'test'. It produces: <foo xmlns:bar="http://bar">test</foo> >- how to define a namespace prefix for an element You send the XMLTagWriter returned by #tag or #tag: #xmlnsAt:put: with the prefix as the first argument and URI as the second. >- how to define a default namespace for an element You send #xmlns: to an XMLTagWriter. Note that this isn't set it stone yet >I think I need another look in the xml parser since last time :) Thanks for putting effort into xml parser. Is there a pull parser available or planned? There are pull parsers on SS but they are (last time I checked) kind of old and may need to be updated. I will look into it eventually. >thanks, > >Norbert > > >_______________________________________________ >Pharo-project mailing list >[hidden email] >http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project > _______________________________________________ Pharo-project mailing list [hidden email] http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project |
Free forum by Nabble | Edit this page |