By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,001 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,001 IT Pros & Developers. It's quick & easy.

ElementTree xmlns:xsi question

P: n/a
Hi there,

I'm generating an XML script using ElementTree which has the following
attributes in the root element:

<CANmessages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="code/can.xsd">

My python script I have written is:

root = Element("CANmessages",
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",
xsi:noNamespaceSchemaLocation="code/can.xsd")

Obviously there is a syntax error inregard to the colons in the
attribute names. I have to have the xsi attributes in there otherwise
the XML won't work correctly. What can I do to make the code correct
and the output being 100% correct as well. Any help would be greatly
appreciated.

Craig

Nov 28 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Craig wrote:
I'm generating an XML script using ElementTree which has the following
attributes in the root element:

<CANmessages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="code/can.xsd">
those are namespace declarations, and mean that tags prefixed by "xsi"
really belongs to the http://www.w3.org/2001/XMLSchema-instance name-
space.
My python script I have written is:

root = Element("CANmessages",
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance",
xsi:noNamespaceSchemaLocation="code/can.xsd")
try:

NS_XSI = "{http://www.w3.org/2001/XMLSchema-instance}"

root = Element("CANmessages")
root.set(NS_XSI + "noNamespaceSchemaLocation", "code/can.xsd")

also see:

http://effbot.org/zone/element.htm#xml-namespaces

</F>

Nov 29 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.