# | User | Message | Date |
867 | Dockimbel | It's a matter of tradeoff, if you only need fast XML document reading, SAX is the winner. If you need to modify the document, you need DOM (with or without SAX). | 4-Jan-10 11:16 |
866 | Pekr | I like SAX model, because IIRC it allows to work on things in a "streamed" way, whereas DOM requires you load everything in memory? Sorry if I oversimpilifed it :-) IIRC Doc used such aproach in his Postgress SQL driver, in opposite to his mySQL one ... | 4-Jan-10 9:38 |
865 | BrianH | The semantic model of REBOL protocol schemes, implemented with the port! type, would fix well with the semantic model of SAX pull. SAX pull generates the same SAX events, except they are not propagated through callbacks - instead they are returned from function calls. SAX pull is sort of like an generator (in the Icon or Python sense) of SAX events. That is very similar in model to the behavior of command ports (like database ports). | 3-Jan-10 19:31 |
864 | Janko | BrianH: What does that mean "port model"? | 3-Jan-10 13:52 |
863 | Janko | Robert: it's a good idea but not for my case. I don't want the data strucure from whole xml , I want to stream it through parser and collect out the data. Geomol: I will look at it but probably not what I want in this particular case for the reason above Gregg: I haven't tested any yet, I googled and found that xml-parse.r above , which has sax style of work but seems huge. I only care to support the simplified subset of xml, xml with all the variants is a total bloat so I believe it can be that complex (and it doesn't support 100% of it also). Thats why I am considering writing a simple sax liek parser, I wrote it in c once and it was small (but it parsed even smaller subset of xml) | 3-Jan-10 13:51 |
862 | BrianH | SAX pull parsing would work well with the port model. | 2-Jan-10 22:47 |
861 | Gregg | I believe Maarten has done a SAX style parser. I've used parse-xml in the past, sometimes post-processing the output to a different REBOL form, but my needs were simple. Janko, have you tested any of the existing soluitions, with test input on target hardware, and found them to be too slow? If so, what were the results, and how fast do you need it to be? | 2-Jan-10 22:44 |
860 | Geomol | Janko, rebxml is a rebol version of xml. It can do the same things, but without the bad implementation, xml suffers from. The idea behind xml is ok, it's just not implemented well. Much of that is solved with the rebxml format. | 2-Jan-10 22:43 |
859 | Robert | Wouldn't it make a lot more sense to use a C based XML parser, construct a Rebol data-structure/string and return that to Rebol? | 2-Jan-10 22:36 |
858 | Janko | thanks Geomol, I will study the links .. xml2rebxml seems short which is nice, but I haven't yet figured out what exactly rebxml is .. I am reading the first link you gave me | 2-Jan-10 22:24 |
857 | Geomol | Janko, http://www.fys.ku.dk/~niclasen/rebxml/rebxml-spec.html http://www.rebol.org/view-script.r?script=xml2rebxml.r http://www.rebol.org/view-script.r?script=rebxml2xml.r | 2-Jan-10 22:08 |
856 | Janko | yes, I get a big xml made by "official" BLOATED standard for invoices .. I want to parse it as quick as possible and that's all | 2-Jan-10 22:07 |
855 | Graham | Mine is a desktop application .. your needs for a web service differ .. | 2-Jan-10 21:54 |
854 | Janko | I imagine that is too costly .. I preferr the callback model to just extract the relevant data out | 2-Jan-10 21:53 |
853 | Graham | You can turn the xml file into a rebol object with it | 2-Jan-10 21:52 |
852 | Graham | Yes, I have used it to parse large XML files | 2-Jan-10 21:52 |
851 | Janko | I will need a xml parser .. I was thinkinf something fast and quick like sax style .. I found this one http://www.rebol.org/view-script.r?script=xml-parse.r but by looking of it it seems to offer a lot of things I don't need. Has anyone used it for "serrious" xml parsing with it. I am thinking of making my own simple minimal event based xml parser. | 2-Jan-10 19:22 |
850 | Graham | Sounds like too much overhead ... unzip the docx, make changes to the xml portion and then rezip. | 15-Aug-09 9:56 |
849 | Graham | There's a rebzip script which has recently been updated on rebol.org which I guess can be used to open up docx | 15-Aug-09 9:20 |
848 | Graham | So, looks feasible to use your parser to create an api for googledocs ... | 15-Aug-09 1:23 |
847 | Chris | >> entry: first entries >> id: first entry/get-by-tag <resourceId> >> id/space == <gd> | 15-Aug-09 0:59 |
846 | Chris | Note that while it appears namespaces have been stripped, they are in fact still there: | 15-Aug-09 0:57 |
845 | Chris | >> google-xml: load-xml/dom clipboard:// ; copied from page >> entries: google-xml/get-by-tag <entry> == [make object! [ name: <entry> space: none value: [ #etag {"BxAUSh5RAyp7ImBq"} <... >> foreach entry entries [probe entry/get <resourceId>] "spreadsheet:key" == "spreadsheet:key" | 15-Aug-09 0:56 |
844 | Graham | again .. how would you use your parser to exxtract the <gd:resourceid> tags and associated text? | 14-Aug-09 20:43 |
843 | Graham | Given some xml like this which is a list of documents http://code.google.com/apis/documents/docs/2.0/developers_guide_protocol.html#ListDocs how would your parser extract the <gd:resourceid> and text associated with these tags? | 14-Aug-09 20:42 |
842 | Chris | Doesn't go into much detail, but: http://www.ross-gill.com/page/XML+and+REBOL | 14-Aug-09 13:03 |
841 | Graham | Chris, do you documentation yet for your parser? | 14-Aug-09 8:39 |
840 | Graham | I'm guessing that it should be "all-stats/get-by-id" and not "stats/get-by-id" | 14-Aug-09 1:41 |
839 | Chris | Still seems to work as advertised - good for extraction; still missing the 'flatten function. Not much time for development in the schema direction though : ( | 13-Aug-09 12:20 |
838 | Graham | How is your parser getting on these days? | 13-Aug-09 2:07 |
837 | Chris | >> do http://www.ross-gill.com/r/altxml.r
connecting to: www.ross-gill.com
Script: "AltXML" (7-Jun-2009)
>> all-stats: load-xml/dom your-xml-data
>> player: stats/get-by-id "b.11965"
>> his-stats: first player/get-by-tag <stats-baseball-offensive>
>> his-stats/get #hits
== "1" >> remove-each code codes: all-stats/get-by-tag <sports-content-code> ["league" <> code/get #code-type] == [make object! [ name: <sports-content-code> space: none value: [ #code-type "league" ... >> foreach code codes [probe code/get #code-name] "Major ^/ League Baseball" == "Major ^/ League Baseball" | 13-Aug-09 1:14 |
836 | Graham | Good luck with this stuff .. it's pretty tedious navigating thru large objects like this ... | 3-Aug-09 1:45 |
835 | CharlesW | Thank you so much Graham, I will give it a try as you have indicated and will alsodownload anamonitor300.r | 3-Aug-09 0:41 |
834 | Graham | make that "straight forward" vs "easy" | 2-Aug-09 21:06 |
833 | Graham | It should be easy enough to write a recurseive function that descends thru the object looking for some text, and then to print out the full path for you as in the recursive examples I posted above. | 2-Aug-09 21:04 |
832 | Graham | if you download anamonitor300.r, then you can browse the object like this mon data mon obj won't work because of the ":" in the object name | 2-Aug-09 21:02 |
831 | Graham | >> do %xml-parse.r Script: "A more XML 1.0 compliant set of XML parsing tools." (4-Dec-2001) >> do %xml-object.r Script: {Convert an XML-derived block structure into objects.} (29-Sep-2001) >> obj: first reduce xml-to-object parse-xml+ read %test.xml >> data: second obj == [make object! [ xts:sports-content-set: make object! [ sports-content: make object! [ sports... >> type? data == block! >> probe data/2/sports-content/sports-event/team/1/player/1 make object! [ player-metadata: make object! [ name: make object! [ value?: "" first: "Matt" last: "Kemp" ] position-event: "8" player-key: "l.mlb.com-p.11965" status: "starter" ] player-stats: make object! [ player-stats-baseball: make object! [ stats-baseball-offensive: make object! [ value?: "" runs-scored: "0" at-bats: "4" hits: "1" rbi: "2" bases-on-balls: "0" strikeouts: "0" singles: "1" doubles: "0" triples: "0" home-runs: "0" grand-slams: "0" sac-flies: "0" sacrifices: "0" grounded-into-double-play: "0" stolen-bases: "0" stolen-bases-caught: "1" hit-by-pitch: "0" average: ".271" ] stats-baseball-defensive: make object! [ value?: "" errors: "0" errors-passed-ball: "0" ] ] ] id: "b.11965" ] | 2-Aug-09 20:59 |
830 | CharlesW | It reads and parses ok. I get the block object but my problem is trying to access the individual elements. When venturing into some of the nested attributes, I just can't seem to get it returning a result.. Can you post an example on how you would retrieve the "hits" for <player id="b.11965"> or get the league info from sports-content-code code-type="league" | 2-Aug-09 15:00 |
829 | Graham | parse-xml and xml-to-object seems to work okay on this file. | 2-Aug-09 4:37 |
828 | CharlesW | Is there a more sutiable language for parsing the XML? | 2-Aug-09 1:56 |
827 | CharlesW | I<?xml version="1.0"?> <xts:sports-content-set xmlns:xts="http://www.xmlteam.com" query-date-time="20090724T011802-0400" query-string="http://fod.xmlteam.com/api-trial/getDocuments?doc-ids=xt.9140271-box" hostname="fod.xmlteam.com" result-count="1" error-count="0" elapsed-time="64.2ms"><sports-content xmlns:str="java.lang.String" xmlns:dt="http://xsltsl.org/date-time" xmlns:xts="http://www.xmlteam.com" xmlns:exsl="http://exslt.org/common" path-id="baseball/l.mlb.com/event-summary/xt.9140271-box" xts:systemid="MLB_Boxscore_XML" xts:tsnid="9140271"> <sports-metadata xmlns:fs="java.io.File" date-time="20090323T193000-0400" doc-id="xt.9140271-box" xts:tsnslug="AAX%BOX-LOS-ANA" language="en-US" revision-id="l.mlb.com-2009-e.26882-event-stats-sportsnetwork.com" fixture-key="event-stats" document-class="event-summary" fixture-name="Box Score"> <sports-title>Boxscore: LA Angels vs. Los Angeles</sports-title> <sports-content-codes> <sports-content-code code-name="The Sports Network" code-key="sportsnetwork.com" code-type="publisher"/> <sports-content-code code-name="XML Team Solutions, Inc." code-key="xmlteam.com" code-type="distributor"/> <sports-content-code code-type="sport" code-key="15007000" code-name="Baseball"/> <sports-content-code code-type="league" code-key="l.mlb.com" code-name="Major League Baseball"/> <sports-content-code code-type="season-type" code-key="pre-season"/> <sports-content-code code-type="season" code-key="2009"/> <sports-content-code code-type="priority" code-key="normal"/> <sports-content-code code-type="conference" code-key="c.national" code-name="National"/> <sports-content-code code-type="conference" code-key="c.american" code-name="American"/> <sports-content-code code-type="team" code-key="l.mlb.com-t.11" code-name="Los Angeles Angels"/> <sports-content-code code-type="team" code-key="l.mlb.com-t.28" code-name="Los Angeles Dodgers"/> <sports-content-code code-type="action-listing" code-key="complete"/> </sports-content-codes> </sports-metadata> <sports-event xmlns:fs="java.io.File"> <event-metadata xmlns:xte="www.xmlteam.com/xte" date-coverage-type="event" event-key="l.mlb.com-2009-e.26882" date-coverage-value="l.mlb.com-2009-e.26882" event-status="post-event" duration="2:58" start-date-time="20090323T160500-0400" xts:game-of-day="1"> <sports-content-codes/> <event-metadata-baseball/> <site> <site-metadata> <home-location/> </site-metadata> <site-stats attendance="8704"/> </site> </event-metadata> <team> <team-metadata team-key="l.mlb.com-t.28" alignment="away"> <name first="Los Angeles" last="Dodgers"/> </team-metadata> <team-stats score="4" score-opposing="10" event-outcome="loss"> <sub-score period-value="1" score="1"/> <sub-score period-value="2" score="0"/> <sub-score period-value="3" score="0"/> <sub-score period-value="4" score="3"/> <sub-score period-value="5" score="0"/> <sub-score period-value="6" score="0"/> <sub-score period-value="7" score="0"/> <sub-score period-value="8" score="0"/> <sub-score period-value="9" score="0"/> <team-stats-baseball> <stats-baseball-offensive runs-scored="4" at-bats="36" hits="9" rbi="4" bases-on-balls="2" strikeouts="4" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="1" stolen-bases="1" stolen-bases-caught="1" hit-by-pitch="0" left-on-base="7"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> <stats-baseball-pitching runs-allowed="10" hits="13" earned-runs="10" bases-on-balls="6" strikeouts="8" era="10.000" balks="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" shutouts="0" games-complete="0" wins="0" losses="1"/> </team-stats-baseball> </team-stats> <player id="b.11965"> <player-metadata position-event="8" player-key="l.mlb.com-p.11965" status="starter"> <name first="Matt" last="Kemp"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="4" hits="1" rbi="2" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="1" hit-by-pitch="0" average=".271"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.7103"> <player-metadata position-event="8" player-key="l.mlb.com-p.7103" status="bench"> <name first="Jason" last="Repko"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".219"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.9917"> <player-metadata position-event="9" player-key="l.mlb.com-p.9917" status="starter"> <name first="Andre" last="Ethier"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="3" hits="2" rbi="0" bases-on-balls="1" strikeouts="0" singles="2" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".204"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.6892"> <player-metadata position-event="pr,7" player-key="l.mlb.com-p.6892" status="bench"> <name first="John-Ford" last="Griffin"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="0" rbi="0" bases-on-balls="0" strikeouts="1" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".000"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.3810"> <player-metadata position-event="dh" player-key="l.mlb.com-p.3810" status="starter"> <name first="Manny" last="Ramirez"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="3" hits="0" rbi="0" bases-on-balls="0" strikeouts="2" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="1" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".200"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.9776"> <player-metadata position-event="ph,dh" player-key="l.mlb.com-p.9776" status="bench"> <name first="A.J." last="Ellis"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="1" rbi="0" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".320"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.6773"> <player-metadata position-event="3" player-key="l.mlb.com-p.6773" status="starter"> <name first="James" last="Loney"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="4" hits="1" rbi="0" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".241"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.5664"> <player-metadata position-event="3" player-key="l.mlb.com-p.5664" status="bench"> <name first="Doug" last="Mientkiewicz"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="0" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".238"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.13237"> <player-metadata position-event="2" player-key="l.mlb.com-p.13237" status="starter"> <name first="Russell" last="Martin"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="3" hits="2" rbi="1" bases-on-balls="0" strikeouts="0" singles="2" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="1" stolen-bases-caught="0" hit-by-pitch="0" average=".394"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.7897"> <player-metadata position-event="2" player-key="l.mlb.com-p.7897" status="bench"> <name first="Danny" last="Ardoin"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".375"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.2687"> <player-metadata position-event="5" player-key="l.mlb.com-p.2687" status="starter"> <name first="Mark" last="Loretta"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".250"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.14163"> <player-metadata position-event="5" player-key="l.mlb.com-p.14163" status="bench"> <name first="Luis" last="Maza"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="1" rbi="0" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".100"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.17507"> <player-metadata position-event="4" player-key="l.mlb.com-p.17507" status="starter"> <name first="Blake" last="DeWitt"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="0" rbi="0" bases-on-balls="0" strikeouts="1" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".288"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.1347"> <player-metadata position-event="4" player-key="l.mlb.com-p.1347" status="bench"> <name first="Juan" last="Castro"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".436"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.14313"> <player-metadata position-event="7,9" player-key="l.mlb.com-p.14313" status="starter"> <name first="Xavier" last="Paul"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="3" hits="0" rbi="0" bases-on-balls="1" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".383"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.18742"> <player-metadata position-event="6" player-key="l.mlb.com-p.18742" status="starter"> <name first="Chin-Lung" last="Hu"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="4" hits="1" rbi="1" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".316"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.8512"> <player-metadata position-event="1" player-key="l.mlb.com-p.8512" status="starter"> <name first="Chad" last="Billingsley"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="4" innings-pitched="2" hits="4" earned-runs="4" bases-on-balls="3" strikeouts="2" era="6.35" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="1" xts:losses-season="1" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.5381"> <player-metadata position-event="1" player-key="l.mlb.com-p.5381" status="bench"> <name first="Jeff" last="Weaver"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="2" innings-pitched="2" hits="3" earned-runs="2" bases-on-balls="0" strikeouts="2" era="7.88" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="1" saves-blown="0" saves="0" event-credit="loss" xts:wins-season="0" xts:losses-season="1" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.18258"> <player-metadata position-event="1" player-key="l.mlb.com-p.18258" status="bench"> <name first="Scott" last="Elbert"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="0" innings-pitched="1" hits="1" earned-runs="0" bases-on-balls="0" strikeouts="1" era="6.14" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="1" xts:losses-season="0" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.7482"> <player-metadata position-event="1" player-key="l.mlb.com-p.7482" status="bench"> <name first="Erick" last="Threets"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="2" innings-pitched="1" hits="1" earned-runs="2" bases-on-balls="1" strikeouts="2" era="5.40" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="0" xts:losses-season="0" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.19392"> <player-metadata position-event="1" player-key="l.mlb.com-p.19392" status="bench"> <name first="Ramon" last="Troncoso"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="2" innings-pitched="1" hits="3" earned-runs="2" bases-on-balls="1" strikeouts="0" era="7.88" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="0" xts:losses-season="1" xts:saves-season="1" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.14165"> <player-metadata position-event="1" player-key="l.mlb.com-p.14165" status="finished"> <name first="Brian" last="Mazone"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="0" innings-pitched="1" hits="1" earned-runs="0" bases-on-balls="1" strikeouts="1" era="0.00" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="0" xts:losses-season="0" xts:saves-season="1" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> </team> <team> <team-metadata team-key="l.mlb.com-t.11" alignment="home"> <name first="Los Angeles" last="Angels"/> </team-metadata> <team-stats score="10" score-opposing="4" event-outcome="win"> <sub-score period-value="1" score="2"/> <sub-score period-value="2" score="2"/> <sub-score period-value="3" score="0"/> <sub-score period-value="4" score="2"/> <sub-score period-value="5" score="0"/> <sub-score period-value="6" score="2"/> <sub-score period-value="7" score="2"/> <sub-score period-value="8" score="0"/> <sub-score period-value="9"/> <team-stats-baseball> <stats-baseball-offensive runs-scored="10" at-bats="34" hits="13" rbi="10" bases-on-balls="6" strikeouts="8" doubles="2" triples="1" home-runs="3" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="1" stolen-bases="0" stolen-bases-caught="2" hit-by-pitch="0" left-on-base="6"/> <stats-baseball-defensive errors="3" errors-passed-ball="0"/> <stats-baseball-pitching runs-allowed="4" hits="9" earned-runs="3" bases-on-balls="2" strikeouts="4" era="3.000" balks="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" shutouts="0" games-complete="0" wins="1" losses="0"/> </team-stats-baseball> </team-stats> <player id="b.6445"> <player-metadata position-event="5" player-key="l.mlb.com-p.6445" status="starter"> <name first="Chone" last="Figgins"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="1" rbi="1" bases-on-balls="1" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="2" hit-by-pitch="0" average=".325"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.20376"> <player-metadata position-event="ph,8" player-key="l.mlb.com-p.20376" status="bench"> <name first="Coby" last="Smith"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="1" rbi="0" bases-on-balls="0" strikeouts="1" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".667"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.11967"> <player-metadata position-event="4" player-key="l.mlb.com-p.11967" status="starter"> <name first="Howie" last="Kendrick"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="0" rbi="0" bases-on-balls="1" strikeouts="2" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".344"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.7011"> <player-metadata position-event="ph,2" player-key="l.mlb.com-p.7011" status="bench"> <name first="Ryan" last="Budde"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="0" rbi="0" bases-on-balls="1" strikeouts="1" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".412"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.5533"> <player-metadata position-event="7" player-key="l.mlb.com-p.5533" status="starter"> <name first="Bobby" last="Abreu"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="2" hits="0" rbi="0" bases-on-balls="1" strikeouts="2" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".263"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.11570"> <player-metadata position-event="5" player-key="l.mlb.com-p.11570" status="bench"> <name first="Brandon" last="Wood"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="2" hits="1" rbi="0" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="1" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".354"/> <stats-baseball-defensive errors="1" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.1946"> <player-metadata position-event="9" player-key="l.mlb.com-p.1946" status="starter"> <name first="Vladimir" last="Guerrero"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="3" hits="2" rbi="0" bases-on-balls="0" strikeouts="0" singles="2" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".250"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.19314"> <player-metadata position-event="9" player-key="l.mlb.com-p.19314" status="bench"> <name first="Chris" last="Pettit"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="2" hits="1" rbi="0" bases-on-balls="0" strikeouts="1" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".354"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.2062"> <player-metadata position-event="8" player-key="l.mlb.com-p.2062" status="starter"> <name first="Torii" last="Hunter"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="3" hits="1" rbi="2" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="1" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".182"/> <stats-baseball-defensive errors="1" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.15871"> <player-metadata position-event="4" player-key="l.mlb.com-p.15871" status="bench"> <name first="Sean" last="Rodriguez"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".282"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.18447"> <player-metadata position-event="3" player-key="l.mlb.com-p.18447" status="starter"> <name first="Kendry" last="Morales"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="3" hits="0" rbi="0" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".367"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.7262"> <player-metadata position-event="3" player-key="l.mlb.com-p.7262" status="bench"> <name first="Matthew" last="Brown"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="1" hits="0" rbi="1" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".550"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.6012"> <player-metadata position-event="dh" player-key="l.mlb.com-p.6012" status="starter"> <name first="Juan" last="Rivera"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="2" hits="1" rbi="0" bases-on-balls="0" strikeouts="1" singles="0" doubles="1" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".211"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.5647"> <player-metadata position-event="ph,dh" player-key="l.mlb.com-p.5647" status="bench"> <name first="Gary" last="Matthews"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="1" hits="0" rbi="0" bases-on-balls="1" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".357"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.6928"> <player-metadata position-event="2" player-key="l.mlb.com-p.6928" status="starter"> <name first="Jeff" last="Mathis"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="2" hits="1" rbi="1" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="1" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".343"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.6814"> <player-metadata position-event="ph,6" player-key="l.mlb.com-p.6814" status="bench"> <name first="Maicer" last="Izturis"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="1" hits="1" rbi="1" bases-on-balls="1" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".278"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.8016"> <player-metadata position-event="6" player-key="l.mlb.com-p.8016" status="starter"> <name first="Erick" last="Aybar"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="2" at-bats="2" hits="2" rbi="2" bases-on-balls="0" strikeouts="0" singles="0" doubles="1" triples="0" home-runs="1" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".310"/> <stats-baseball-defensive errors="1" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="b.6589"> <player-metadata position-event="ph,7" player-key="l.mlb.com-p.6589" status="bench"> <name first="Robb" last="Quinlan"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="1" at-bats="2" hits="1" rbi="2" bases-on-balls="0" strikeouts="0" singles="0" doubles="0" triples="0" home-runs="1" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="0" hit-by-pitch="0" average=".310"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.7092"> <player-metadata position-event="1" player-key="l.mlb.com-p.7092" status="starter"> <name first="Dustin" last="Moseley"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="4" innings-pitched="6" hits="8" earned-runs="3" bases-on-balls="1" strikeouts="3" era="3.15" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="1" losses="0" saves-blown="0" saves="0" event-credit="win" xts:wins-season="3" xts:losses-season="0" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.20390"> <player-metadata position-event="1" player-key="l.mlb.com-p.20390" status="bench"> <name first="Trevor" last="Reckling"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="0" innings-pitched="2" hits="1" earned-runs="0" bases-on-balls="1" strikeouts="0" era="0.00" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="0" xts:losses-season="0" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> <player id="p.20370"> <player-metadata position-event="1" player-key="l.mlb.com-p.20370" status="finished"> <name first="Mason" last="Tobin"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-pitching runs-allowed="0" innings-pitched="1" hits="0" earned-runs="0" bases-on-balls="0" strikeouts="1" era="0.00" balks="0" shutouts="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" wins="0" losses="0" saves-blown="0" saves="0" xts:wins-season="0" xts:losses-season="0" xts:saves-season="0" xts:saves-blown-season="0"/> </player-stats-baseball> </player-stats> </player> </team> <officials> <official> <official-metadata position="Home Plate Umpire"> <name full="Jim Wolf"/> </official-metadata> </official> <official> <official-metadata position="First Base Umpire"> <name full="Bob Davidson"/> </official-metadata> </official> <official> <official-metadata position="Second Base Umpire"> <name full="Mike Winters"/> </official-metadata> </official> <official> <official-metadata position="Third Base Umpire"> <name full="Mike Everitt"/> </official-metadata> </official> </officials> <event-actions> <event-actions-baseball/> </event-actions> <highlight class="double-plays"> <p>Los Angeles 2; LA Angels 1.</p> </highlight> </sports-event> </sports-content></xts:sports-content-set> | 2-Aug-09 1:53 |
826 | Graham | Rebol's open source xml parsers are not fully complete. Where is the full XML file that the fragment comes from? | 2-Aug-09 1:27 |
825 | CharlesW | Using rebelxml.r I have tried: get-xml-data/content/with-attribute 'xts:sports-content-set/sports-content/sports-metadata/sports-content-codes '/sports-content-code/code-type "sport" and many variations of this statement. Using: obj-xml I have tried variations of obj-xml/document/xts-sports-content-set/sports-content/sports-metadata/sports-content-codes/sports-content-code/value? As an example I tried to pull out the league information but could not, However I was able to pull out the TITLE using obj-xml/document/xts-sports-content-set/sports-content/sports-metadata/ sports-title/value? Obviously, I am clueless, so if anyone can point me in the right direction for a well document library (Hopefully with examples) that would be great. Otherwise if there is something glaring that I am doing wrong, please let me know. Thanks, Charlie | 1-Aug-09 17:34 |
824 | CharlesW | Here is the snipped of XMl: <?xml version="1.0"?> <xts:sports-content-set xmlns:xts="http://www.xmlteam.com" query-date-time="20090724T011802-0400" query-string="http://fod.xmlteam.com/api-trial/getDocuments?doc-ids=xt.9140271-box" hostname="fod.xmlteam.com" result-count="1" error-count="0" elapsed-time="64.2ms"><sports-content xmlns:str="java.lang.String" xmlns:dt="http://xsltsl.org/date-time" xmlns:xts="http://www.xmlteam.com" xmlns:exsl="http://exslt.org/common" path-id="baseball/l.mlb.com/event-summary/xt.9140271-box" xts:systemid="MLB_Boxscore_XML" xts:tsnid="9140271"> <sports-metadata xmlns:fs="java.io.File" date-time="20090323T193000-0400" doc-id="xt.9140271-box" xts:tsnslug="AAX%BOX-LOS-ANA" language="en-US" revision-id="l.mlb.com-2009-e.26882-event-stats-sportsnetwork.com" fixture-key="event-stats" document-class="event-summary" fixture-name="Box Score"> <sports-title>Boxscore: LA Angels vs. Los Angeles</sports-title> <sports-content-codes> <sports-content-code code-name="The Sports Network" code-key="sportsnetwork.com" code-type="publisher"/> <sports-content-code code-name="XML Team Solutions, Inc." code-key="xmlteam.com" code-type="distributor"/> <sports-content-code code-type="sport" code-key="15007000" code-name="Baseball"/> <sports-content-code code-type="league" code-key="l.mlb.com" code-name="Major League Baseball"/> <sports-content-code code-type="season-type" code-key="pre-season"/> <sports-content-code code-type="season" code-key="2009"/> <sports-content-code code-type="priority" code-key="normal"/> <sports-content-code code-type="conference" code-key="c.national" code-name="National"/> <sports-content-code code-type="conference" code-key="c.american" code-name="American"/> <sports-content-code code-type="team" code-key="l.mlb.com-t.11" code-name="Los Angeles Angels"/> <sports-content-code code-type="team" code-key="l.mlb.com-t.28" code-name="Los Angeles Dodgers"/> <sports-content-code code-type="action-listing" code-key="complete"/> </sports-content-codes> </sports-metadata> <sports-event xmlns:fs="java.io.File"> <event-metadata xmlns:xte="www.xmlteam.com/xte" date-coverage-type="event" event-key="l.mlb.com-2009-e.26882" date-coverage-value="l.mlb.com-2009-e.26882" event-status="post-event" duration="2:58" start-date-time="20090323T160500-0400" xts:game-of-day="1"> <sports-content-codes/> <event-metadata-baseball/> <site> <site-metadata> <home-location/> </site-metadata> <site-stats attendance="8704"/> </site> </event-metadata> <team> <team-metadata team-key="l.mlb.com-t.28" alignment="away"> <name first="Los Angeles" last="Dodgers"/> </team-metadata> <team-stats score="4" score-opposing="10" event-outcome="loss"> <sub-score period-value="1" score="1"/> <sub-score period-value="2" score="0"/> <sub-score period-value="3" score="0"/> <sub-score period-value="4" score="3"/> <sub-score period-value="5" score="0"/> <sub-score period-value="6" score="0"/> <sub-score period-value="7" score="0"/> <sub-score period-value="8" score="0"/> <sub-score period-value="9" score="0"/> <team-stats-baseball> <stats-baseball-offensive runs-scored="4" at-bats="36" hits="9" rbi="4" bases-on-balls="2" strikeouts="4" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="1" stolen-bases="1" stolen-bases-caught="1" hit-by-pitch="0" left-on-base="7"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> <stats-baseball-pitching runs-allowed="10" hits="13" earned-runs="10" bases-on-balls="6" strikeouts="8" era="10.000" balks="0" errors-wild-pitch="0" number-of-pitches="0" number-of-strikes="0" shutouts="0" games-complete="0" wins="0" losses="1"/> </team-stats-baseball> </team-stats> <player id="b.11965"> <player-metadata position-event="8" player-key="l.mlb.com-p.11965" status="starter"> <name first="Matt" last="Kemp"/> </player-metadata> <player-stats> <player-stats-baseball> <stats-baseball-offensive runs-scored="0" at-bats="4" hits="1" rbi="2" bases-on-balls="0" strikeouts="0" singles="1" doubles="0" triples="0" home-runs="0" grand-slams="0" sac-flies="0" sacrifices="0" grounded-into-double-play="0" stolen-bases="0" stolen-bases-caught="1" hit-by-pitch="0" average=".271"/> <stats-baseball-defensive errors="0" errors-passed-ball="0"/> </player-stats-baseball> </player-stats> </player> | 1-Aug-09 17:25 |
823 | CharlesW | Folks, I have gone through this forum with the hopes that I woul''nt bother you with a newb style question. I have been trying all sorts of different xml libraries (rebelxml.r, xml-parse.r, xml-object.r) as well as a few others I found. No matter what I do, I can't seem to pull the values I need. | 1-Aug-09 17:25 |
822 | Graham | so, this is an attempt to remedy this fix-object: func [obj [object!] /local o value? ] [ foreach element next first obj [ if object? o: get in obj element [ ; is object, so check to see if has value? either value?: in o 'value? [ set in obj element trim/head/tail get value? ] [ fix-object o ] ] if block? o [ foreach ob o [ fix-object ob ] ] ] ] | 6-Jul-09 0:09 |
821 | Graham | If xml-to-object meets a xml file with a number of elements with the same name, it creates a block of objects. | 6-Jul-09 0:08 |
820 | Graham | It's an object because xml-to-object creates them that way :( | 29-Jun-09 20:20 |
819 | Gabriele | i see, your problem was that next first o is a block. if you also want to make sure there's nothing else in the object (but then... why is it an object?), you could check [value?] = next first o or [self value?] = first o | 29-Jun-09 10:57 |
818 | Graham | I did want to make sure that value? was the first member of the object | 29-Jun-09 10:20 |
817 | Graham | Your suggestion looks good :) | 29-Jun-09 10:17 |
816 | Graham | I think I tried either 'value? = next first o but I couldn't figure out why that didn't work ... | 29-Jun-09 10:16 |
815 | Gabriele | you can add value? to /local and then do either value?: in o 'value? [ ... get value?] | 29-Jun-09 9:14 |
814 | Gabriele | why not either in o 'value? ? | 29-Jun-09 9:13 |
813 | Graham | Anyway this is looking promising. I can take an xml message, construct a rebol object from it ... rearrange bits to create a new object and then create a reply xml message. | 28-Jun-09 11:06 |
812 | Graham | Proably the source of my earlier issues | 28-Jun-09 11:04 |
811 | Graham | I've also noticed that xml-to-object has to be run on a copy .... it must alter the original data block it is fed | 28-Jun-09 11:04 |
810 | Graham | I've only tested it once :) | 28-Jun-09 11:03 |
809 | Sunanda | Much neater than my hack! | 28-Jun-09 11:01 |
808 | Graham | or not | 28-Jun-09 10:59 |
807 | Graham | ie. should be /local o | 28-Jun-09 10:59 |
806 | Graham | ooops ... doesn't need the /loca | 28-Jun-09 10:58 |
805 | Graham | fix-object: func [ obj [object!]
/local prev
][
foreach element next first obj [
if object? o: get in obj element [
; is object, so check to see if has value?
either "value?" = form next first o [
set in obj element trim/head/tail get in o 'value?
][
fix-object o
]
]
]
] this fixes up the object created by xml-to-object | 28-Jun-09 10:57 |
804 | Graham | Looks good ... I can cope :) | 28-Jun-09 9:44 |
803 | Sunanda | As I said, you may need to tidy things up.....I wrote some code to do that, but it is hardwired for the particular dataset i was using. | 28-Jun-09 9:35 |
802 | Graham | value?: | 28-Jun-09 9:13 |
801 | Graham | creates a value element for each value :( | 28-Jun-09 9:12 |
800 | Graham | cool .. | 28-Jun-09 8:54 |
799 | Graham | oh ...sorry | 28-Jun-09 8:53 |
798 | Graham | Hmm. There is no 'xml-object function | 28-Jun-09 8:52 |
797 | Sunanda | This works for me:
do %xml-object.r
xml-file: read %my-xml-file.xml
xml-object: first reduce xml-to-object parse-xml xml-file Though the resulting object does need some tidying up | 28-Jun-09 8:44 |
796 | Graham | I keep getting errors | 28-Jun-09 8:19 |
795 | Graham | Got a working example of their use? | 28-Jun-09 8:19 |
794 | Sunanda | Both parse XML. The main difference is:
-- xml-object.r uses REBOL's built-in mezzanine, parse-xml
-- parse-xml.r is an improvement for parse-xml In theory, you could use both together. In my experience, xml-object.r is all I need to parse XML ..... the XML I encounter just does not need the extra oomph supplied by parse-xml.r | 28-Jun-09 7:49 |
793 | Graham | that's the complementary script ... | 28-Jun-09 7:42 |
792 | Sunanda | Don't remember if I tried parse-xml. I do use xml-object wich works well for me: http://www.rebol.org/view-script.r?script=xml-object.r | 28-Jun-09 7:33 |
791 | Graham | has anyone got a working copy of parse-xml.r from the library? | 28-Jun-09 7:26 |
790 | Geomol | In case, it's needed, RebXML spec: http://www.fys.ku.dk/~niclasen/rebxml/rebxml-spec.html | 24-Jun-09 21:13 |
789 | BrianH | indermediate -> intermediate | 24-Jun-09 14:07 |
788 | BrianH | That's because the "intermediate" contexts don't really indermediate - they get applied in order by DO. | 24-Jun-09 14:06 |
787 | BrianH | Functions can be serialized, but the only word contexts that get restored are the global and thee function local context. Any intermediate contexts, like object contexts, don't get restored. | 24-Jun-09 14:03 |
786 | Sunanda | [we're off topic for XML -- please continue in Library if you want more details]. Stored in text files and binary files (which are generally just compressed text files. No database! | 24-Jun-09 9:00 |
785 | Graham | I'm pretty sure rebol.org doesn't use a db backend. | 24-Jun-09 8:43 |
784 | Graham | and these are stored where? In the filing system? | 24-Jun-09 8:42 |
783 | Graham | Interesting... | 24-Jun-09 8:41 |
782 | Sunanda | We have similar issues at REBOL.org where just about everything [scripts, Ml posts, internal data structures, etc] is objects, or blocks of objects. Data sanitisation and object upgrading is a major part of the gig. | 24-Jun-09 8:30 |
781 | Graham | And when my app crashes as it does often enough, I save state as an object .. and that has to be checked as well when reloaded. | 24-Jun-09 8:19 |
780 | Graham | I have configs that are saved in the db as objects ... and those i have to check each time :( | 24-Jun-09 8:19 |
779 | Sunanda | That makes life a bit simpler.....Objects with year-long lifespans can be harder to manage :) | 24-Jun-09 8:14 |
778 | Graham | and then I can discard it ... | 24-Jun-09 8:13 |
777 | Graham | What I need to do is to create the object, create the xml from the object, and then submit it via ssl to the gateway server | 24-Jun-09 8:13 |
776 | Graham | I'll just change the object templates | 24-Jun-09 8:12 |
775 | Sunanda | You may have some other issues to consider as part of building/loading the data structures. For example, Version2 of the application adds some fields not present in V1. To avoid a one-off bulk conversion exercise, the load process needs to check each object and add missing fields with default values. | 24-Jun-09 8:09 |
774 | Maxim | ok. | 24-Jun-09 8:06 |
773 | Graham | I'll be creating an empty object and then populating it once created | 24-Jun-09 8:04 |
772 | Maxim | if the db returns lists of varying length and types... you're better off creating a structured approach to a recursive initialisation. | 24-Jun-09 8:03 |
771 | Maxim | well if the pharmacy object can have 1 or 5 addresses, some people 3 different ways to refer to patients, etc... then the copy still has to be meddled with. | 24-Jun-09 8:02 |
770 | Graham | what do you nean by structure has to remain pretty static? | 24-Jun-09 8:01 |
769 | Graham | deep copy | 24-Jun-09 8:00 |
768 | Maxim | talking to who? | 24-Jun-09 8:00 |
767 | Graham | what do you mean? | 24-Jun-09 8:00 |
766 | Maxim | but note that your object's structure has to remain pretty static for any type of deep copy like this to be usefull. | 24-Jun-09 8:00 |
765 | Sunanda | Do has some dangers if you do not trust the code involved. This works for me, and keeps the load/all (but not the self).....Even more tortured: a: first reduce load/all mold pharmacy | 24-Jun-09 7:59 |
764 | Maxim | not really, the way I see it is that we are taking advantage of rebol's features. | 24-Jun-09 7:59 |
763 | Graham | This solution seems a little tortued :) | 24-Jun-09 7:57 |
762 | Maxim | yes since I removed the make. | 24-Jun-09 7:55 |
761 | Graham | a: do mold pharmacy ; | 24-Jun-09 7:55 |
760 | Maxim | a: do mold pharmacy [ ] | 24-Jun-09 7:53 |
759 | Graham | so, I have to now do a: do load mold make pharmacy [ ] ? | 24-Jun-09 7:52 |
758 | Sunanda | It worked for me, when i tried it. | 24-Jun-09 7:51 |
757 | Maxim | ok, to use do, you must forget the /all. so the above, minus the /all should work with self... (it does in my tests) | 24-Jun-09 7:50 |
756 | Graham | because it won't work? | 24-Jun-09 7:49 |
755 | Maxim | seems functions can be serialized, but I don't understand why the self isn't being bound to the object..that is strange. | 24-Jun-09 7:49 |
754 | Sunanda | Why not remove the self ? [not a metaphysical question in this context] ph: make object! [ name: none init: func [n][ name: n ] ] | 24-Jun-09 7:47 |
753 | Maxim | functions cannot be serialized... so they have to be bound somehow. | 24-Jun-09 7:45 |
752 | Maxim | if you have a function inside, I think you have to do it instead of load it. | 24-Jun-09 7:45 |
751 | Graham | seems not :( >> pharmacy: make object! [ [ name: none [ init: func [ n ][ [ self/name: n [ ] [ ] >> a: load mold/all make pharmacy [] >> probe a make object! [ name: none init: func [n][ self/name: n ] ] >> a/init "testing" ** Script Error: self has no value ** Where: init ** Near: self/name: n | 24-Jun-09 7:43 |
750 | Graham | ahh ... well problem solved :) | 24-Jun-09 7:13 |
749 | Maxim | yes. | 24-Jun-09 7:13 |
748 | Graham | ie. I load a serialized form of the object | 24-Jun-09 7:12 |
747 | Graham | So, I can continue to make the objects as I have been doing. But just before I use it ... I load mold/all on it to ensure I have unique objects | 24-Jun-09 7:12 |
746 | Maxim | but remember to use mold/ALL cause otherwise you end up with gibberish... | 24-Jun-09 7:11 |
745 | Maxim | ex: load mold/all make object! [ a: make object! [ b: make object! [ c: "tadam!" ] ] ] will effectively create a complete duplicate of the whole object tree. | 24-Jun-09 7:10 |
744 | Graham | I was just thinking that. | 24-Jun-09 7:10 |
743 | Maxim | you can just do a mold/all load, that will in effect copy the whole tree along with all the series too. | 24-Jun-09 7:09 |
742 | Graham | Let me understand this .. if I have an object that needs other objects more than 1 deep .. I can't use that to clone other objects without creating references instead of copies. | 24-Jun-09 7:08 |
741 | Maxim | the downside is that access either needs a wrapper func, or is done via indexes... actually attributes could be an object, since their names are mutually exclusive within an element. | 24-Jun-09 7:06 |
740 | Maxim | what I can suggest is that you build your objects like so: xml-attribute: context [ name: "someattr" value: "somevalue" ] xml-tag: context [ name: "FileID" content: [] ; a block of inner xml-tag objects attributes: [] ; a block of xml-attribute names ] then all you do is nest objects in objects, filling them up item by item recursively using DB data. | 24-Jun-09 7:04 |
739 | Graham | this is part of the xsd .. found an example http://stackoverflow.com/questions/790118/jaxb-types-problem | 24-Jun-09 6:47 |
738 | Graham | it's all in a DB. | 24-Jun-09 6:45 |
737 | Graham | well, output is first, reading is the next task :) | 24-Jun-09 6:45 |
736 | Maxim | what is the source of data? | 24-Jun-09 6:45 |
735 | Maxim | MUCH easier than loading it. | 24-Jun-09 6:44 |
734 | Maxim | you only need to output xml? then that is very easy. | 24-Jun-09 6:44 |
733 | Graham | Maybe I need to use the factory way .. | 24-Jun-09 6:44 |
732 | Graham | I'm creating the XML from scratch .. and not reading it in. | 24-Jun-09 6:43 |
731 | Maxim | my client has a few thousand data types to cope with ;-) rebxml allows you to load that up pretty quickly...but not using the xsd obviously. its parser builds up a string and then loads it. I found it to be quite fast actually. its MUCH faster than firefox, for example. | 24-Jun-09 6:42 |
730 | Graham | The XSD I'm looking at has about 30-40 complex data types | 24-Jun-09 6:40 |
729 | Graham | A hack. | 24-Jun-09 6:39 |
728 | Maxim | ;-) | 24-Jun-09 6:38 |
727 | Maxim | >> probe load replace {#[object! [a: #[object! [b: #[object! [c: "%VALUE%"]]]]]]} "%VALUE%" "tadam!" make object! [ a: make object! [ b: make object! [ c: "tadam!" ] ] ] | 24-Jun-09 6:38 |
726 | Maxim | something like... | 24-Jun-09 6:36 |
725 | Maxim | cause with rebol its easy to hack stuff up using out of the box tricks..... | 24-Jun-09 6:36 |
724 | Graham | static largely | 24-Jun-09 6:35 |
723 | Maxim | does the xml structure change a lot (lists of data, alternative or optional elements, etc) or is it really static? | 24-Jun-09 6:34 |
722 | Maxim | in the later, you can add code in the addressobj which will be executed everytime you create an object using it. for example: addressobj: [ number: 666 street: "styx lane" city: "pandemonium" address: rejoin [number " " street " " city] ] | 24-Jun-09 6:33 |
721 | Graham | I'm having to create nested objects 7 levels deep ... | 24-Jun-09 6:32 |
720 | Maxim | so graham... instead of doing: ; note this is an object, context is a shortcut for make object! , like func is a shortcut for make function! addressobj: context [ number: 666 street: "styx lane" city: "pandemonium" ] pharmacy: context [ address: make addressobj [ ] ] you do: ; note this is a block addressobj: [ number: 666 street: "styx lane" city: "pandemonium" ] pharmacy: context [ address: context addressobj ] | 24-Jun-09 6:30 |
719 | BrianH | The spec block is like an init function that goes away after it runs, without needing to assign none to any fields. | 24-Jun-09 6:25 |
718 | Maxim | that is how its done in GLayout to assign the same setup to many styles. | 24-Jun-09 6:25 |
717 | Maxim | thats another ways of doing it... instead of storing reference objects you store reference spec blocks. | 24-Jun-09 6:25 |
716 | BrianH | Code in the spec block doesn't get attached to the object. | 24-Jun-09 6:24 |
715 | Graham | huh? | 24-Jun-09 6:23 |
714 | Sunanda | One way to do init is as open code in the object....That only "inits" the original object, not anything MAKEd from it. But it may be useful in some cirumstances, and it does not become part of the object: o: make object! compose [print "init" (a: 99) a: 1 b: 2] | 24-Jun-09 6:21 |
713 | Graham | Using your method of creating a special context is going to screw up my obj2xml function :( | 24-Jun-09 6:19 |
712 | Graham | i wouldn't have 100s of init functions anymore .. :) | 24-Jun-09 6:17 |
711 | Maxim | not much would really be gained, but it migh trigger some GC cleanup. | 24-Jun-09 6:17 |
710 | Graham | I guess I can set the init functions to none after they've done their jobs ? | 24-Jun-09 6:16 |
709 | Maxim | I usually creat myself a new function which calls make and the object init (wether class or prototype based) if that init needs to create new inner objects, then its responsible for doing so. in your case the make-xml-object could accept an xml string and then call make-xml-object recursively for each element it finds. | 24-Jun-09 6:15 |
708 | BrianH | OOP in a prototype-based language with function values instead of methods is different. Classes are emulated if need be, but don't always need to be. In REBOL even delegation is explicit, unlike most other prototype-based object languages. For the best maintenance use factory functions that create objects based on standard specs. Beyond that, different models are better for different tasks. Sometimes you assign function values to fields, sometimes you use class objects, sometimes class names that are looked up at runtime. | 24-Jun-09 5:40 |
707 | Graham | In terms of maintenance? | 24-Jun-09 5:35 |
706 | Graham | which is the more robust method? | 24-Jun-09 5:34 |
705 | BrianH | If you like. The standard way of doing things in REBOL is to have functions that create objects, rather than constructor methods. | 24-Jun-09 5:33 |
704 | Graham | As you can see, I've never played with rebol objects before ... | 24-Jun-09 5:32 |
703 | Graham | If that is the case, perhaps I need a 'create function with each object, and at init time, iterate thru all the objects calling their create function ? | 24-Jun-09 5:30 |
702 | Graham | so , instead of a: make pharmacy [] I have to a: make pharmacy [ address: make addressobj []] | 24-Jun-09 5:27 |
701 | BrianH | Every MAKE object! takes a spec block that is an init function, in effect. | 24-Jun-09 5:25 |
700 | BrianH | With explicit construction in the spec block, like this: a: make proto [ b: make inner-proto [...] ] | 24-Jun-09 5:24 |
699 | Graham | Create them using the init function ?? | 24-Jun-09 5:24 |
698 | Graham | So, how does one create nested unique objects? | 24-Jun-09 5:22 |
697 | Graham | Ouch | 24-Jun-09 5:22 |
696 | BrianH | Yeah. | 24-Jun-09 5:21 |
695 | Graham | so if I have pharmacy: make object! [ address: make addressobj [ ] ] and the address object has objects in it ... they will be shared?? | 24-Jun-09 5:21 |
694 | BrianH | But then the class functions are accessed through obj/class/method obj, insstead of obj/method. | 24-Jun-09 5:19 |
693 | Graham | is it objects within objects within objects? | 24-Jun-09 5:18 |
692 | Graham | Oh .... | 24-Jun-09 5:17 |
691 | Maxim | R2 shares objects within objects. the class is not re-created at each make []. | 24-Jun-09 5:15 |
690 | Maxim | but its a large object. still using the class system, I can allocate 1000000 nodes using about 400MB. with instances, 10000 obects take much more than that. | 24-Jun-09 5:14 |
689 | Graham | unclear as to why yours is shared and mine isn't | 24-Jun-09 5:14 |
688 | Graham | well, I doubt that I would have more than a few hundred objects... but ... | 24-Jun-09 5:14 |
687 | Maxim | with liquid the difference is staggering when over 10000 objects. | 24-Jun-09 5:13 |
686 | Maxim | my example above, will share the init function amongst all the 2000 objects... and its going to be faster since no binding occurs... well only the CLASS word is bound but its content is the same in all instances. | 24-Jun-09 5:11 |
685 | Graham | what's the diff between yours and mine? | 24-Jun-09 5:11 |
684 | Maxim | it is bound each time, so if you have 2000 instances, you actually have 2000 times that function in ram, it adds up quickly for larger objects... for such a simple object, it might not be all that bad... | 24-Jun-09 5:10 |
683 | Graham | Perhaps I'm not clear on this ....
If I create a pharmacy object like this pharmacy: make object! [ name: none init: func [ n ][ self/name: n ] ] is the init function shared by all the subsequent pharmacy instances? | 24-Jun-09 4:56 |
682 | Graham | That's what i was going to do initially, but I thought it would be easier to maintain if I kept the init methods inside the objects | 24-Jun-09 4:47 |
681 | Maxim | class is shared amongst all my-tag instances, and is never bound to any of them, so its both very fast and very RAM efficient.. exponentially so with large classes. | 24-Jun-09 3:59 |
680 | Maxim | the init is a context with one function, to which you supply the outer (instance) which holds the data: my-tag: context [ data: "tototo" attribute-1: "red" class: context [ init: func [instance][ instance/data: copy "" instance/attribute-1: copy "blue" ] ] ] to init the an instance of my-tag: new-tag: make my-tag [class/init self] | 24-Jun-09 3:58 |
679 | BrianH | Class-based objects are emulated in REBOL. | 24-Jun-09 3:56 |
678 | Maxim | yes, the best method is to have some form of dtd or schema, and use class-based objects. | 24-Jun-09 3:55 |
677 | BrianH | Not a good idea for data objects, which could number in the thousands, each with their own bound copy of the functions. | 24-Jun-09 3:54 |
676 | Graham | Using objects means i can store the functions that initialize it inside the object. | 24-Jun-09 3:52 |
675 | Graham | that's why I said "if" ... | 23-Jun-09 23:37 |
674 | Graham | at this time .. it may come back to you | 23-Jun-09 23:37 |
673 | Maxim | read above, I don't ;-) | 23-Jun-09 23:35 |
672 | Graham | as should i. | 23-Jun-09 23:35 |
671 | Graham | You should add a comment to the discussion page if you remember. | 23-Jun-09 23:35 |
670 | Maxim | I remeber it also tripping on some of the XML files I gave it... don't remember the problems... but its error handling /recovery was very shaky IIRC. | 23-Jun-09 23:34 |
669 | Graham | I suspect the author is no longer reboling | 23-Jun-09 23:31 |
668 | Graham | even if the full path is specified. | 23-Jun-09 23:30 |
667 | Graham | it accepts the first one it finds | 23-Jun-09 23:30 |
666 | Graham | rebelxml gets confused if there is more than one path with the same name | 23-Jun-09 23:29 |
665 | Maxim | but the rebxml tools (on rebol.org) as-is are very usefull, so some utf-8 support and are less buggy than rebelXML in my previous tests. | 23-Jun-09 23:26 |
664 | Graham | Ok, so we have established that everyone does it their own way :) | 23-Jun-09 23:24 |
663 | Maxim | anyhow... the xml tools I currently have are not yet tested enough to be release ready. | 23-Jun-09 23:11 |
662 | Maxim | my newer version doesn't have the schema validation process.... that is a very complex engine to build. schemas and Parse traversal do not follow the same algorythm... so its a bitch to implement. | 23-Jun-09 23:10 |
661 | BrianH | And mine is lost :( | 23-Jun-09 23:10 |
660 | Maxim | but all of that is not open source. | 23-Jun-09 23:09 |
659 | Maxim | oops.. embedded text I mean. | 23-Jun-09 23:09 |
658 | Maxim | my engine does support embedded types, but ignored it by default... it was also byte reversible... a loaded xml block loaded through the engine was saved back exactly, byte for byte, checksum proofed. | 23-Jun-09 23:08 |
657 | BrianH | I was parsing xhtml and other XML of the like. Subelements of mixed types in order with text between them than mattered. | 23-Jun-09 23:07 |
656 | Maxim | my paths.. namespace works... for sure. did you know you can have colon in word names in R2 ! but i didn;t use that, I just used tags directly. more obvious than strings, and the exact same effort and speed. | 23-Jun-09 23:06 |
655 | BrianH | Your paths can't access multiple subelements of the same type, or embedded text. It might have worked for that customer but not the general case. No namespace support either. | 23-Jun-09 23:05 |
654 | Maxim | a later version, using schema validation, understands multiple subelements and automatically converts them to blocks IIRC. so you do document/element/3/subelement/#attribute. | 23-Jun-09 23:05 |
653 | Graham | Looks like we need an article on best practices here ... | 23-Jun-09 23:04 |
652 | Maxim | I wanted direct access to all elements within rebol. | 23-Jun-09 23:03 |
651 | BrianH | I wrote a simple xpath compiler too (but don't know where it is now). | 23-Jun-09 23:03 |
650 | BrianH | XML *is* case-sensitive. Your paths can't access multiple subelements of the same type, or embedded text. | 23-Jun-09 23:02 |
649 | Graham | by position! | 23-Jun-09 23:02 |
648 | Maxim | but brian, how do you acess it? | 23-Jun-09 23:01 |
647 | Graham | XML can be case sensitive?? | 23-Jun-09 23:01 |
646 | Maxim | hahaha | 23-Jun-09 23:00 |
645 | Maxim | its just that in my tests, either you can create, read or set some of the datatypes via path notation. so only string based types allow full XML qualification. | 23-Jun-09 23:00 |
644 | BrianH | My positional version handles multiple subelements of the same type, and using strings rather than words lets you use tags that don't match word syntax or are case=sensitive. | 23-Jun-09 23:00 |
643 | Maxim | note that in the above, you can replace types within so it could be words instead of tags. | 23-Jun-09 22:58 |
642 | Graham | Using tags looks ugly :) | 23-Jun-09 22:58 |
641 | BrianH | Really? I went positional: ["element" "namespace" ["attribute" "value"] ["subelement" ...] "text" ...] with missing namespace or attribute block being #[none], so defaults can be done with ANY. | 23-Jun-09 22:57 |
640 | Maxim | I've never posted that specific version cause it was closed source for a client. but I have my own new engine, which does the same, but attacking the parse rules directly... its probably faster. I've not released it. | 23-Jun-09 22:57 |
639 | Graham | I guess the duplicate elements could be solved by using blocks for them | 23-Jun-09 22:57 |
638 | Graham | I find working with objects much easier though ... | 23-Jun-09 22:56 |
637 | Maxim | And you can access it this way: document/<element>/<subelement>/#attribute document/<element>/<subelement>/. | 23-Jun-09 22:55 |
636 | Maxim | the . is assigned the value of the elements. the above would result from the following XML: <element> <subelement attribute="attr-value"> subelement content </subelement> </element> | 23-Jun-09 22:54 |
635 | Maxim | the most stable engine I built which accepted all xml possibilities ended loading xml like so: [ <element> [<subelement> [#attribute "attr-value" . "subelement content"]]] | 23-Jun-09 22:52 |
634 | Graham | Have you posted your modifications anywhere?? | 23-Jun-09 22:52 |
633 | Graham | Or name spaces | 23-Jun-09 22:51 |
632 | Graham | Although the XML I'm dealing with doesn't have duplicate elements. | 23-Jun-09 22:51 |
631 | Maxim | and you can easily separate attributes from elements, just by affecting them to different types. | 23-Jun-09 22:50 |
630 | Graham | True | 23-Jun-09 22:50 |
629 | Maxim | cause you have have the same element severall times, which is valid xml, but invalid in contexts. | 23-Jun-09 22:50 |
628 | Maxim | yes all the time. accessing is exactly the same as for objects. its actually much more flexible. | 23-Jun-09 22:49 |
627 | Graham | So, you used blocks instead of objects? | 23-Jun-09 22:48 |
626 | Maxim | (...objects instead of blocks ....) | 23-Jun-09 22:46 |
625 | Maxim | building output objects instead would be simple, but the RAM/Speed/symbol table implications of all the binding involved makes this un-optimal. | 23-Jun-09 22:46 |
624 | Maxim | I also replaced the use of url for the tag words because they fail when using namespaced xml elements. | 23-Jun-09 22:44 |
623 | Maxim | a modified version of John's rebXML tools. changed the output structure to allow rebol's path notation to be used to traverse the loaded xml. | 23-Jun-09 22:42 |
622 | Graham | What are people using to construct large XML documents ... of 100s of lines? | 23-Jun-09 22:41 |
621 | Graham | I was using rebelxml to construct xml ... but I came across some bugs. So this way of doing it looks easier .... | 23-Jun-09 1:44 |
620 | Graham | remove the newlines to solve that issue :) | 23-Jun-09 0:02 |
619 | Graham | format-xml: func [ xml
/local out space prev
][
out: copy ""
spacer: copy ""
prev: copy </tag>
foreach tag load/markup xml [
either tag = find tag "/" [
; we have a close tag
; reduce the spacer by a tab unless the previous was an open tag
either not tag? prev [
; not a tag
remove/part spacer 4
][
; is a tag
if prev = find prev "/" [
; last was a closing tag
remove/part spacer 4
]
]
][
either tag? tag [
; current is tag
; indent only if the prev is not a closing tag
if not prev = find prev "/" [
insert/dup spacer " " 4
]
][
; is data
insert/dup spacer " " 4
]
]
repend out rejoin [ spacer tag newline ]
prev: copy tag
]
view layout compose [ area (out) 400x400 ]
] obj2xml: func [ obj [object!] out [string!] /local o ][ foreach element next first obj [ repend out [ to-tag element ] either object? o: get in obj element [ obj2xml o out ][ repend out any [ o copy "" ] ] repend out [ to-tag join "/" element ] ] ] | 23-Jun-09 0:02 |
618 | Steeve | then, for NONE! values, it will add an empty line | 22-Jun-09 23:59 |
617 | Graham | probably should change line repend out [ o newline ] to repend out [ any [ o copy "" ] newline ] | 22-Jun-09 23:57 |
616 | Graham | Yes, separate script does the tabulations | 22-Jun-09 23:52 |
615 | Steeve | Hmm.. Really, have you the tabulations ? | 22-Jun-09 23:51 |
614 | Graham | gives this <a> testing </a> <b> again </b> <c> <d> testing2 </d> <e> again2 </e> <f> <g> testing3 </g> <h> again3 </h> </f> </c> <i> finished </i> | 22-Jun-09 23:49 |
613 | Graham | >> probe obj make object! [ a: "testing" b: "again" c: make object! [ d: "testing2" e: "again2" f: make object! [ g: "testing3" h: "again3" ] ] i: "finished" ] | 22-Jun-09 23:48 |
612 | Graham | crap ... clipboard bug | 22-Jun-09 23:48 |
611 | Graham | using this obj2xml: func [ obj [object!] out [string!] /local o ][ foreach element next first obj [ repend out [ to-tag element newline ] either object? o: get in obj element [ obj2xml o out ][ repend out [ o newline ] ] repend out [ to-tag join "/" element newline ] ] ] | 22-Jun-09 23:47 |
610 | Graham | This seems to work for me ... obj2xml: func [ obj [object!] out [string!] /local o ][ foreach element next first obj [ repend out [ to-tag element newline ] either object? o: get in obj element [ obj2xml o out ][ repend out [ o newline ] ] repend out [ to-tag join "/" element newline ] ] ] | 22-Jun-09 23:42 |
609 | Gregg | There must be something, but I don't have anything here that turned up, and I don't remember doing one myself. If it helps, you could use the JSON converter in %json.r as a starting point. | 22-Jun-09 22:00 |
608 | Graham | Now has anyone written a recursive routine to turn a rebol object into XML? I couldn't find anything like this on rebol.org yet it doesn't sound hard to do ... | 22-Jun-09 13:49 |
607 | Graham | No matter .. it was easy enough. | 22-Jun-09 13:49 |
606 | Graham | /indent .. not index | 22-Jun-09 10:52 |
605 | Graham | Has anyone written anything to format/index XML documents? | 22-Jun-09 10:52 |
604 | Geomol | RebXML spec: http://www.fys.ku.dk/~niclasen/rebxml/rebxml-spec.html Scripts are in the Library: http://www.rebol.org | 2-Mar-09 16:12 |
603 | Chris | Ok, another revision. This has a few more methods, I may strip them down to read-only, as I don't need to manipulate the object though I left them in for completeness. >> do http://www.ross-gill.com/r/qdom.r connecting to: www.ross-gill.com Script: "QuickDOM" (none) >> doc: load-dom {<some><xml id="foo">to try</xml></some>} >> foo: doc/get-by-id "foo" >> foo/name == <xml> >> foo/value == [ /id "foo" # "to try" ] >> kids: foo/children == [make object! [ name: # value: "to try" tree: [ # "to try" ] position: [ ... >> kids/1/value == "to try" >> doc/tree/<some>/<xml>/(#) == "to try" | 4-Dec-08 15:11 |
602 | Chris | This is not an exercise in bloat, I plan to implement only a few key methods. Though if anyone has any requests? | 3-Dec-08 13:40 |
601 | Chris | ; You can still parse the tree too: parse doc/tree [<some> into [<xml> "to try"]] | 3-Dec-08 13:36 |
600 | Chris | do http://www.ross-gill.com/r/qdom.r doc: load-dom {<some><xml>to try</xml></some>} values: doc/get-by-tagname <xml> values/1/value = "to try" | 3-Dec-08 13:35 |
599 | Chris | Only one method at the moment - get-by-tagname Note, this is not an attempt to implement W3 DOM. Just a quick approximation for fast manipulation (hence the name). It's object happy, not sure of the weight considerations as such. | 3-Dec-08 13:33 |
598 | Chris | ; Next, Quick DOM: do http://www.ross-gill.com/r/qdom.r | 3-Dec-08 13:31 |
597 | Chris | So ymmv depending on need. | 3-Dec-08 13:30 |
596 | Chris | Note, this parser is destructive - ie. flattening will only provide an approximation of the original xml string. | 3-Dec-08 13:29 |
595 | Chris | All the 'into values are a bit of a pain, but work can be broken up... | 3-Dec-08 5:38 |
594 | Chris | response: context [
status: name: value: none
] example: {<rsp> <status>Good</status> <payload> <value name="one">two</value> </payload> </rsp>} probe make response [ parse load-xml example [ <rsp> into [ <status> set status ["Good" | "Bad"] <payload> into [ <value> into [ /name set name string! # set value string! ] ] ] ] ] | 3-Dec-08 5:36 |
593 | Chris | >> load-xml "<try>This</try>" == [ <try> "This" ] | 3-Dec-08 5:31 |
592 | Chris | Also, a tag with no attributes containing only text will only contain text: | 3-Dec-08 5:30 |
591 | Chris | I thought about the # convention. # can be used in parse literally. It may have no semantic meaning, but is a very concise anchor. | 3-Dec-08 5:29 |
590 | Chris | Hmm, missing bracket. | 3-Dec-08 5:27 |
589 | Chris | >> load-xml {<some xml="to">Try</some>} == [ <some> /xml "to" # "Try" ] ] | 3-Dec-08 5:26 |
588 | Chris | Where 'thing is <tag> /attribute or # for text. And value is [container] "text" or none | 3-Dec-08 5:24 |
587 | Chris | More consistent, I feel. The result is now of the format: some [thing value] | 3-Dec-08 5:24 |
586 | Chris | I've changed this a little. More or less parseable. | 3-Dec-08 5:22 |
585 | Chris | Sorry! | 20-Nov-08 0:56 |
584 | Chris | Sorry, [tag! any [refinement! [string! | none!]] [string! | none! | some block!]] | 20-Nov-08 0:56 |
583 | Gregg | Cool. | 20-Nov-08 0:53 |
582 | Chris | A tag block will always be [tag! any [refinement! [string! | none!]] [string! | none! | block!]] | 20-Nov-08 0:49 |
581 | Chris | Sorry, forgot I'd assigned pop: :take -- try again. | 20-Nov-08 0:48 |
580 | Gregg | ** Script Error: pop has no value ** Where: load-xml ** Near: mk: insert mk: back mk | 20-Nov-08 0:47 |
579 | Chris | ; Usage: do http://www.ross-gill.com/r/qxml.r load-xml {<some xml="to">Try</some>} | 20-Nov-08 0:45 |
578 | Chris | This is a quickie -- designed to make 'parse-xml output more parseable: http://www.ross-gill.com/r/qxml.r Any thoughts, comments? | 20-Nov-08 0:44 |
577 | Steeve | or worst, as u want | 11-Nov-08 22:25 |
576 | Steeve | oh i have a better bad puns: GUI-lty | 11-Nov-08 22:25 |
575 | Steeve | oh you're here... | 11-Nov-08 22:16 |
574 | Steeve | *still | 11-Nov-08 22:15 |
573 | Steeve | is Henrik steel working on revamping ? | 11-Nov-08 22:14 |
572 | Steeve | the first time i saw his new styles, i had some glue in my eyes | 11-Nov-08 22:12 |
571 | Henrik | it's at times like that, that REBOL deserves advertising with a live demo. | 11-Nov-08 22:12 |
570 | Geomol | :) | 11-Nov-08 22:08 |
569 | Steeve | It's also a refernce to the "special" talent of Carl in terms of mixing colors ;-) | 11-Nov-08 22:07 |
568 | Geomol | REBOL is GLUE! What about calling the new GUI something related to glue? Or just "GLUE". | 11-Nov-08 21:59 |