Hi Guys,
I've spent a while puzzling this, but after reading the v. useful BasicLibraries.pdf and searching the web I'm still stumped. I'd be very grateful for any pointers: I want to produce an XML document where the top node refers to its schema: <RecordUpdates xmlns="http://www.foo.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="..."> </RecordUpdates> How do I get the xsi:schemaLocation bit in there? Is it just an attribute? I tried this: | xml | xml := XML.Document new. xml addNode: ((XML.Element tag: 'MyNode') attributes: (Array with: (XML.Attribute name: 'xsi:schemaLocation' value: '...'))). xml root namespaces: ((Dictionary new) at: '' put: 'http://www.foo.com'; at: 'xsi' put: 'http://www.w3.org/2001/XMLSchema-Instance'; yourself). But then the xsi:schemaLocation bit comes out first, before the namespace stuff. I don't even know if this matters, but I'm trying to exactly replicate a piece of XML given to me as a template. Previously I thought the xsi:schemaLocation went in the namespace dictionary, but then it comes out as xmlns:xsi:schemaLocation which is wrong, isn't it? Any help, sarcastic or otherwise, gratefully recieved. ... John |
Hi John,
I'm not an XML expert, but it sounds like your results are OK. If there's an xmlns attribute anywhere within an element, that is the namespace of the element itself (and of its attributes, unless they state otherwise). Similarly if within an element there is an attribute defining an alias for a namespace, e.g. xmlns:xsi="...", then anywhere within that element and its subelements you can use the xsi: prefix.
So, the order of attributes within an element doesn't matter. VisualWorks likes to put them in alphabetical order, IIRC, and I've not tried messing with that. Of course VisualWorks accepts them in any order, as it should.
All the best,
Steve Lähettäjä: [hidden email] puolesta: johnhwoods Lähetetty: la 30/07/2011 13:47 Vastaanottaja: [hidden email] Aihe: [vwnc] Noob XML - adding xsi attribute (if it is one) to root node Hi Guys, _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |