You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Stefan Brauneis <st...@gmd.de> on 2001/05/22 12:26:46 UTC
How to set an attribute value to NULL?
Hi all,
well, I don't know exactly but maybee this is more a problem of
understanding xml in my mind then a real xerces prob, but anyway I
would be apreciate for your help.
I would like to do the following:
I have an element in an xml-doc which has an attribute with a default
value given in the dtd.
But when I parse the doc with the attribute-value given as an empty
string (like attr="") the attribute will be overwritten by the default
value! But I don't want this to happen. I thought that an attribute is
only substituted by the default when it is not present at all in the
element. Or in other words, why doesn't the parser distinguish
between an empty attribute value and the absence of the attribute at
all?
An other problem is pretty similar:
When I parse the same document I am trying to manipulate the above
mentioned attribute value, it is not possible to set it to NULL or an
empty string! What is happining is that the value is not manipulated at
all!
Well, to recapitulate: My question is
1. Is it possible to tell the parser to distinguish between an empty
attribute value and no attribute at all?
2. Is it possible to set an attribute value to an empty string or NULL?
3. If 1 & 2 are answered with no: Is this an xml probleme, a xerces
problem or my own problem ? ;-)
I would be very grateful for any help or advice and I have attached some
code snippets to explain my problems in this way.
cu
stefan
Re: How to check mandatory/optional elements
Posted by Dean Roddey <dr...@charmedquark.com>.
Look at the EnumVal sample program. It shows how to get this info. This is
using internal, non-standard APIs that are supported by the parser. There is
some support for this info in the DOM, but its still light. So you might
have to go to the internal APIs to get what you need.
--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com
"Why put off until tomorrow what you can
put off until the day after tomorrow?"
----- Original Message -----
From: "Stefan Berglund" <st...@telia.se>
To: <xe...@xml.apache.org>
Sent: Tuesday, May 22, 2001 4:01 AM
Subject: How to check mandatory/optional elements
> Hello all,
>
> Is there an easy way to check if a certain element (name given) exists
> somewhere in the DTD(s), and if it's optional or not?
> I've recently started working with Xerces, in a
> communicating-interface-component thingy, using a DOMParser to validate
> messages and then extract certain values from the message and send them
> further on "down the chain" in other formats.
>
> The DTD given in the XML message points further on to another DTD too...
> I've looked among the classes in the hierarchy, but haven't been able to
> figure out what to use for this yet. :-(
>
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org
How to check mandatory/optional elements
Posted by Stefan Berglund <st...@telia.se>.
Hello all,
Is there an easy way to check if a certain element (name given) exists
somewhere in the DTD(s), and if it's optional or not?
I've recently started working with Xerces, in a
communicating-interface-component thingy, using a DOMParser to validate
messages and then extract certain values from the message and send them
further on "down the chain" in other formats.
The DTD given in the XML message points further on to another DTD too...
I've looked among the classes in the hierarchy, but haven't been able to
figure out what to use for this yet. :-(
* Example:
in the xml message (foo1.xml):
...
<!DOCTYPE MESSAGE SYSTEM "FOO1.dtd">
...(tags)...
in FOO1.dtd:
<!ENTITY % FOOResources SYSTEM "FOOResources.dtd">
%FOOResources;
<!ELEMENT MESSAGE (HEADER,FOO1)>
<!ELEMENT FOO1 (element1?, element2...etc)>
in FOOResources.dtd:
<!ENTITY % FOOSegments SYSTEM "FOOSegments.dtd">
%FOOSegments;
....and in FOOSegments.dtd is the HEADER element structure specified. This
is what I want =)
The header element is a standard thing, which is in all messages, so all
messages have a HEADER section plus something else, per message.
So, I would like to check if a certain element, that is a child of HEADER,
exists (is declared somewhere in the DTD:s) and if it's optional or not.
Any help is really appreciated!
/Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-c-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-c-dev-help@xml.apache.org