473,385 Members | 1,409 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Attribute with default value not immediately replaced... !?

Hi everybody...

In Xerces 2.7.0 it is explicitly stated that, no matter how one removes
an attribute
(attList->removeNamedItem, attList->removeNamedItemNS,
domElement->removeAttributeNode, domElement->removeAttribute,
domElement->removeAttributeNS), if that attribute has a default value
it is immediately replaced.
However I cannot obtain that behaviour...

Check out the following schema and document:

SCHEMA
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schema1"
targetNamespace="http://schema1"
elementFormDefault="qualified"
attributeFormDefault="unqualified">
<xsd:element name="subelement" type="subelementType"/>
<xsd:element name="rootelement">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element ref="subelement"/>
</xsd:choice>
</xsd:complexType>
</xsd:element>
<xsd:attribute name="myat" type="xsd:string" default="123"/>
<xsd:complexType name="subelementType">
<xsd:attribute ref="myat"/>
</xsd:complexType>
</xsd:schema>

DOCUMENT
<?xml version="1.0" encoding="UTF-8"?>
<rootelement xmlns="http://schema1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://schema1 schema.xsd">
<subelement/>
</rootelement>

I load the document to a DOM like this:

DOMParser->setDoNamespaces(true);
DOMParser->setDoSchema(true);
DOMParser->setValidationSchemaFullChecking(true);
DOMParser->parse(FileName);

In the DOM constructed, as expected, there is a "myat" attribute for
element "subelement"
having the value of "123". As the latter was declared as a global
attribute in the schema,
it is namespace-qualified (getNamespaceURI() GIVES "http://schema1")
even though
schema has attributeFormDefault="unqualified" (correct me if I'm
wrong...).

So far so good.

Now I'm trying to remove that attribute. No matter which of the above
methods I choose,
I cannot obtain the immediate replacement of this attribute, although
it has a default value.

removeNamedItem causes the creation of a "myat" element, but with no
namespace. All
other methods just remove the attribute and no replacement occurs.

What is going on? Am I missing something?...

Any help would be GREATLY appreciated...

Thanks in advance.

Nicolas

Feb 24 '06 #1
2 1571
Traditionally, default-attribute reinstantiation only worked for
defaults specified in DTDs, not in schemas. As of DOM Level 3, that
*may* (not must) be supported for schemas too. I'd suggest talking to
the folks who wrote your DOM implementation -- the Xerces mailing list
at Apache -- to ask whether that's supported and whether there's a
switch you have to set to enable it.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Feb 24 '06 #2
Ok Joseph, you' re clear....

Thanks!

Nicolas

Feb 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gabriel Genellina | last post by:
Hi In the following code sample, I have: - a Worker class, which could have a lot of methods and attributes. In particular, it has a 'bar' attribute. This class can be modified as needed. - a...
4
by: Lénaïc Huard | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello, I've some namespace problems when defining default values for attributes. My problem seems to come from the fact that the attributes are...
12
by: robertbrown1971 | last post by:
My company is working on a bond derivative portfolio analysis tool and we're facing a problem that I did not see adequately addressed any where in literature. I really did RTFM. I'm very...
2
by: Keith Chadwick | last post by:
Is there a way to append to an attribute in XSLT. For example: <input name="emailaddress" style="width:200px"> <xsl:apply-templates select="//object"/> </input> <xsl:template...
2
by: Bill Cohagan | last post by:
In my app I'm validating an XML file against an XSD which contains several attribute default value specifications. I'm performing the validation via an xml document load() using a...
12
by: Stefano | last post by:
Hi all, what is the correct use of the "default" attribute in XML Schema? For example: <xs:element name="myProperty" type="xs:string" default="myDefaultValue"/> What can I do with it? What...
5
by: AdSR | last post by:
Hi, I'm having a problem with the Amara toolkit. Try this: >>> from amara import binderytools >>> raw = '<pq:test xmlns="http://example.com/namespace" xmlns:pq="http://pq.com/ns2"/>' >>> rwd...
5
by: patrin | last post by:
Hi All, given the source document: <?xml version="1.0" encoding="UTF-8"?> <root> <child> <test id="1" name="first child"/> </child> <child>
5
by: Oleg.Ogurok | last post by:
Hi there, I need to encode the value of an XML attribute, e.g. string myXml = "<element myAttr=\"" + encodeURIComponent("my \"value") + "\"" ...."; Is there an equivalent of...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.