Amara: Where's my attribute?

A

AdSR

Hi,

I'm having a problem with the Amara toolkit. Try this:
<?xml version="1.0" encoding="UTF-8"?>
<pq:test xmlns:pq="http://pq.com/ns2"/>

What happened to the xmlns attribute? Does anyone know a solution to
this? The only workaround I found is to:
<?xml version="1.0" encoding="UTF-8"?>
<pq:test xmlns:pq="http://pq.com/ns2"
xmlns="http://example.com/namespace"/>

but it only helps if you know what to patch.

My setup:

Python 2.4.3
4Suite 1.0b3
Amara 1.0

I see that people have reported similar problems with other XML
toolkits, so I guess this is a general namespace ugliness.

Regards,

AdSR
 
F

Fredrik Lundh

AdSR said:
I'm having a problem with the Amara toolkit. Try this:

<?xml version="1.0" encoding="UTF-8"?>
<pq:test xmlns:pq="http://pq.com/ns2"/>

What happened to the xmlns attribute? Does anyone know a solution to
this?

the documents are 100% identical in XML infoset terms, so what's the problem here ?
I see that people have reported similar problems with other XML toolkits, so I guess this is a
general namespace ugliness.

lack of namespace understanding, more likely.

</F>
 
A

AdSR

Fredrik said:
[cut]
the documents are 100% identical in XML infoset terms, so what's the problem here ?

Looks like the problem is somewere else, after all: Some software
relies on these "unused" xmlns attributes, most notably XML Schema
tools. Which is unfortunate, because xmlns attributes indeed have the
full right to receive special treatment.
lack of namespace understanding, more likely.

May I suggest a saying: Never attribute to lack of knowledge what you
can attribute to confusing signals :)

Yours truly,
AdSR
 
U

uche.ogbuji

AdSR said:
Hi,

I'm having a problem with the Amara toolkit. Try this:

<?xml version="1.0" encoding="UTF-8"?>
<pq:test xmlns:pq="http://pq.com/ns2"/>

What happened to the xmlns attribute? Does anyone know a solution to
this? The only workaround I found is to:

<?xml version="1.0" encoding="UTF-8"?>
<pq:test xmlns:pq="http://pq.com/ns2"
xmlns="http://example.com/namespace"/>

but it only helps if you know what to patch.

My setup:

Python 2.4.3
4Suite 1.0b3
Amara 1.0

I see that people have reported similar problems with other XML
toolkits, so I guess this is a general namespace ugliness.

What is the actual problem you're trying to solve? If you just want to
force a namespace declaration in output (this is sually to support
QNames in content) the most well-known XML hack is to create a dummy
attribute with the needed prefix and namespace. But this does not work
when you're trying to force a default namespace declaration. Then
again, you generally can't use QNames in content with a default
namespace declaration. So my guess is that you somehow got way off the
rails in your problem-solving, and you'll need to provide mre
background if you want help.

BTW, I recommend upgrading to Amara 1.1.7. That branch will soon be
1.2, and I consider it more mature than 1.0 at this point. The API's
also easier:
 
A

AdSR

What is the actual problem you're trying to solve? If you just want to
force a namespace declaration in output (this is sually to support
QNames in content) the most well-known XML hack is to create a dummy
attribute with the needed prefix and namespace. But this does not work
when you're trying to force a default namespace declaration. Then
again, you generally can't use QNames in content with a default
namespace declaration. So my guess is that you somehow got way off the
rails in your problem-solving, and you'll need to provide mre
background if you want help.

I wanted to remove documentation elements from some XML Schema files.
The problem showed when I tried to use the stripped schemas, because
the namespace declaration for user-defined types was missing. Of
course, since these types are named and referred to in attribute
*values*, Amara had no way to know that the namespace declaration was
still needed (didn't matter if default or non-default). This is more a
problem of how XML Schema is defined against XML namespace rules, since
XML Schena uses namespaces in a context of which XML parsers aren't
normally aware.
BTW, I recommend upgrading to Amara 1.1.7. That branch will soon be
1.2, and I consider it more mature than 1.0 at this point. The API's
also easier:

I know, especially the insert-before/after feature :) But I ran into a
problem that I describe below and you advertised 1.0 as "stable
version", so I switched immediately.

The problem can be reproduced like this:
START DTD xs:schema -//W3C//DTD XMLSCHEMA 200102//EN XMLSchema.dtd
http://www.w3.org/2001/datatypes.dtd:99:23: Attribute 'id' already
declared
http://www.w3.org/2001/datatypes.dtd:122:23: Attribute 'id' already
declared
http://www.w3.org/2001/datatypes.dtd:130:27: Attribute 'id' already
declared
....some 40 more lines like this and then Python crashes (Windows shows
the bug-reporting dialog)

Thanks for your interest,

AdSR
 
U

uche.ogbuji

AdSR said:
I wanted to remove documentation elements from some XML Schema files.
The problem showed when I tried to use the stripped schemas, because
the namespace declaration for user-defined types was missing. Of
course, since these types are named and referred to in attribute
*values*, Amara had no way to know that the namespace declaration was
still needed (didn't matter if default or non-default). This is more a
problem of how XML Schema is defined against XML namespace rules, since
XML Schena uses namespaces in a context of which XML parsers aren't
normally aware.

Yeah. Just so you know. This is one of those things about XML that
make sane people want to dye their eyeballs red.

Unfortunately there isn't much recourse but to switch to namespace
qualified form for your QNames and adding dummy attributes so the
namespace is recognized. Let me know if you need an example.

I know, especially the insert-before/after feature :) But I ran into a
problem that I describe below and you advertised 1.0 as "stable
version", so I switched immediately.

The problem can be reproduced like this:

START DTD xs:schema -//W3C//DTD XMLSCHEMA 200102//EN XMLSchema.dtd
http://www.w3.org/2001/datatypes.dtd:99:23: Attribute 'id' already
declared
http://www.w3.org/2001/datatypes.dtd:122:23: Attribute 'id' already
declared
http://www.w3.org/2001/datatypes.dtd:130:27: Attribute 'id' already
declared
...some 40 more lines like this and then Python crashes (Windows shows
the bug-reporting dialog)


I don't get a crash on my system (Ubuntu), but I do get a legitimate
error message because that DTD is broken. The W3C seems to like
disseminating broken DTDs. Just yesterday I was helping someone around
the infamous broken XHTML 1.1 DTDs.

I do want to know why you're gettign a crash rather than just the error
message. What version of Python is that? Any chance you can try with
current CVS Amara (you can use easy_install)? This part of the
discussion should perhaps move to the 4Suite mailing list. I only
check this NG once a week.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top