You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Martin Vysny <vy...@host.sk> on 2005/04/03 17:45:44 UTC

Default attributes

Hi everyone,
  is there a way to turn off the 'DTD default attributes' Xerces
functionality? I would really love to delete attribute A but it's
impossible: when I delete A, another attribute is generated immediately,
with default contents as stated in the DTD. Is there a way to disable
this default attribute generation?
Thanks,
Martin Vysny

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Default attributes

Posted by Martin Vysny <vy...@host.sk>.
Michael Glavassevich wrote:

>Hi Martin,
>
>I assume you're referring to the DOM's behaviour when you remove an 
>attribute that has a default value defined in the DTD. The DOM spec says 
>[1] that a new attribute is added when a default value exists. There's no 
>user option for turning this off, though if you're eventually going to 
>serialize the document you can instruct an LSSerializer [2] to discard 
>default attributes (and content).
>  
>
Hi Michael,
  thank you very much for your response. You really hit the spot -
that's exactly what I wanted. It seems that I must rely on some hack to
get the job done. Actually, I need to get rid of this default attribute
in the deserialization time. Please allow me to describe the problem.
  DTD does not support namespaces - that is a well known fact. The
workaround used by W3C is to specify the xmlns attribute for the root
element with fixed default value equal to the namespace. For some
particular reason I want to modify prefixes of all elements, thus I want
to create xmlns attribute for this prefix. Old xmlns attribute is no
longer needed and thus should be deleted - but that cannot be done so
easily. I found Xerces feature that could help me [1] but it didn't
work. It looks like the best way is to modify prefixes of all elements,
clone root element and replace old root element with the clone - this
clone should have this attribute being removable (because of [2]). This
is quite ineffective, the [1] feature would be really helpful. Is
something like that feature present in Xerces?
  I cannot just delete the <!DOCTYPE declaration because of entities. I
half-resolved this by converting this DTD to RelaxNG (hence validating
using this converted RelaxNG schema), and by deleting all
element/attribute rules from the DTD, using the DTD as container for
entities only. This of course trashes default attributes values.
  What interests me is that there is certain incosistency in this
behaviour. Let us suppose that DTD defines fixed xmlns attribute for the
root element. If root element has null prefix then it contains this
unremovable xmlns attribute. However if root element in XML has non-null
prefix then this unremovable xmlns attribute is not present at all
([2]), even if namespace match. I think I'm missing something in XML
specification here, but really don't know.
  Thank you for your interest,
  Sincerely,
Martin Vysny

[1] http://xml.apache.org/xerces-j/features.html; the
"http://apache.org/xml/features/nonvalidating/load-dtd-grammar" feature


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Default attributes

Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Martin,

I assume you're referring to the DOM's behaviour when you remove an 
attribute that has a default value defined in the DTD. The DOM spec says 
[1] that a new attribute is added when a default value exists. There's no 
user option for turning this off, though if you're eventually going to 
serialize the document you can instruct an LSSerializer [2] to discard 
default attributes (and content).

[1] http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-D589198
[2] 
http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html#parameter-discard-default-content

Martin Vysny <vy...@host.sk> wrote on 04/03/2005 11:45:44 AM:

> Hi everyone,
>   is there a way to turn off the 'DTD default attributes' Xerces
> functionality? I would really love to delete attribute A but it's
> impossible: when I delete A, another attribute is generated immediately,
> with default contents as stated in the DTD. Is there a way to disable
> this default attribute generation?
> Thanks,
> Martin Vysny
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org