World: r3wp
[XML] xml related conversations
older | first |
GrahamC 13-Oct-2010 [881x2] | If there's a function in the object, it drops it. |
posted last year to this group! http://www.rebol.org/aga-display-posts.r?post=r3wp323x568 | |
james_nak 14-Oct-2010 [883] | Thanks Graham. With the way that the programs I am using create the objects, I'm finding that I have to create something pretty specific. I appreciate the thought and code though. |
GrahamC 3-Nov-2010 [884] | Is John's the only rebol utility that turns a rebol representation back into an xml document with attributes? |
Maxim 3-Nov-2010 [885] | check your PMs... (it might not hav turned red.... altme bug) |
Maxim 10-Nov-2010 [886x2] | A question for XML users related to namespaces. is it possible for a tag's attributes to originate from two different namespaces? ex: <tag ns1:attr="data" ns2:other-attr="data"> or even worse: <tag ns1:attr="data" ns2:attr="data"> my gut tells me no, but I've been wrong before in this delightfull world of XML spec overcomplexification . |
FYI, I've just discovered that yes... you can have the same attribute several times in a tag so long as the namespace is different. XML is ... so ... much ... fun.... NOT! | |
Gregg 10-Nov-2010 [888] | I don't like XML, but it makes sense that namespaces prevent collisions. |
Maxim 10-Nov-2010 [889] | yes, its just pretty complicated to manage two attributes of a tag which come from different namespaces... so in the end, what does the attribute really mean. |
Gregg 10-Nov-2010 [890] | Well, if the words has bindings...oh wait, wrong language. ;-) |
Maxim 10-Nov-2010 [891] | hehe, yes it is similar to advanced word usage in REBOL. but xml isn't really a language in my understanding (interpretation) of the word. |
Steeve 10-Nov-2010 [892] | just a dialect with a bad messy syntax... |
Oldes 13-Nov-2010 [893x3] | I just created this function to convert the data tree returned from REBOL's default parse-xml function back to the same string: context [ out: copy "" emitxml: func[dom][ foreach node dom [ either string? node [ out: insert out node ][ foreach [ name atts content ] node [ out: insert out join {<} [name #" "] if atts [ foreach [att val] atts [ out: insert out ajoin [att {="} any [val ""] {" }] ] ] out: remove back out either all [content not empty? content] [ out: insert out #">" emitxml content out: insert out ajoin ["</" name #">"] ][ out: insert out "/>" ] ] ] ] ] set 'xmltree-to-str func[dom][ clear head out emitxml dom head out ] ] |
>> xmltree-to-str third parse-xml {<test arg="1"><bla/>hello</test>} == {<test arg="1"><bla/>hello</test>} | |
I'm not sure if the naming is correct, but I don't care, I need the functionality. | |
GrahamC 13-Nov-2010 [896] | Does it handle name spaces? |
Oldes 14-Nov-2010 [897x5] | do you mean this?: >> print xmltree-to-str third parse-xml {<h:table xmlns:h="http://www.w3.org/TR/html4/"> { <h:tr> { <h:td>Apples</h:td> { <h:td>Bananas</h:td> { </h:tr> { </h:table>} <h:table xmlns:h="http://www.w3.org/TR/html4/"> <h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr> </h:table> |
But REBOL's default parse-xml has limitations, so better use Gavin's http://www.rebol.org/view-script.r?script=xml-parse.rif you must parse some advanced XML doc's. | |
Also it's probably possible to use parse instead of the recursive function call, but it's working for me so I will stay with this one. | |
Just note, that if the source xml is using CDATA, the parsed tree does not contain this info, so the result would be different. >> print xmltree-to-str probe third parse-xml+ {<foo>abc <![CDATA[Jack & Jill]]> xyz</foo> } [["foo" none ["abc Jack & Jill xyz"]]] <foo>abc Jack & Jill xyz</foo> | |
I'm not sure how to awoid this, but fortunately my XML sources must be well formed without CDATA so I'm safe. | |
Chris 23-Nov-2010 [902] | Graham, AltXML dom objects have a 'flatten function that renders xml. It preserves namespaces but not whitespace or cdata as cdata (though I may do a strict version that does both). |
BrianH 11-Mar-2011 [903] | Finally, the work of the W3C binary XML group is an official recommendation: http://www.w3.org/TR/exi/ |
onetom 30-Apr-2011 [904x2] | just an interesing fact: the Relax NG Compact schema description language is a Rebol dialect if i remove the commas from it. |
i tried it on the OAGiS Components.xsd which i transformed to RNG and the to RNC using XMLKit | |
Maxim 2-May-2011 [906:last] | anyone here had issues with receiving Form feed characters in XML (which are illegal in XML 1.0) ? |
older | first |