--On March 30, 2006 2:13:13 PM -0500 David Hampton <[EMAIL PROTECTED]> wrote:

The problem I was seeing is related to the following (class of) line
in the data file:

  <gnc:count-data cd:type="commodity">161</gnc:count-data>

Gnucash writes the <gnc:count-data> tag with an attribute named
'cd:type' but doesn't declare the 'cd' namespace.  (The declaration of
'cd' that you see on line 6 of the data file is in the wrong scope.)
When a validating xml parser reads this attribute it on input, it
ignores the attribute leaving gnucash with no idea of what the number
161 applies to.  This was considered a parse error and caused the
loading of the data file to be considered a failure even though all
the data was read.  Also since all counts to be loaded are zero,
gnucash has no way to properly update the progress bar.

I believe that this is a misunderstanding of XML namespaces. A namespace prefix declared on a tag can be used on any attribute on that tag or any tag in the contents of that tag. I've spent much of the last few months making namespaces work better in Arbortext Epic editor, so I'm fairly familiar with them right now. One of the test cases I used to debug this is attached to this message. It contains

<emphasis xmlns:pre2="www.uri.com">
<pre2:tag pre2:attr="pre2val" pre2:glarp="pre2glarp">Namespaced
tag</pre2:tag>
</emphasis>

This declares the pre2 prefix on the emphasis tag and uses it on an attribute in the enclosed pre2:tag tag. It doesn't matter that the prefix on the tag name is the same as on the attribute name.

Another example from the test file (leaving out the contents of the table and part of the para) is

<para xmlns:pre1="www.uri.com" pre1:attr="pattr">
<table pre1:attr="table">
</table>
<pre1:tag pre1:attr="attrValue" pre1:glarp="glarp1">Namespaced tag
</pre1:tag>
</para>

Here the pre1 prefix is used on an attribute on the table tag. I wanted to make sure that the table editor preserved namespace qualified attributes when you edited the table.

I think that the use of the "cd" prefix by gnucash was legal as it stood. You're right that it's unusual to use namespace prefixes on attribute names, but it's legal.

--
Mike Alexander           [EMAIL PROTECTED]
Ann Arbor, MI            PGP key ID: BEA343A6

Attachment: namespace-test.xml
Description: Binary data

_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to