Hi,

It's valid to define a property value as follows if the property type is a simple type such as xsd:string.

   <property name="prop1">ABC</property>

The isTextForProperty flag stays true if no elements are encountered under <property>.

When we read the property value into a DOM document, the value cannot be validated as the type might be unknown at this point. This leads to corner cases such as:

1) <property name="prop1"></property>
2) <property name="prop1"/>

The XML spec [1] has two statements about content of an element:

a) "The text between the start-tag and end-tag is called the element's content." b) "An element with no content is said to be empty.] The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag."

According to b), 1 and 2 are equivalent and we should report the violation if "mustSupply" is true.

But now what's the value to set prop1 to "" if its type is xsd:string?

3) <property name="prop1" value=""></property>
4) <property name="prop1"><value></value></property>

I'm sure 3 is valid. 4 seems to have a value without content. Is it the same as 1 & 2?

if there are some characters in the content for the property or value element, then I assume the "mustSupply" is satisfied and it becomes a matter of value validity. For example, if the type cannot accept the text as the literal value, for example "xsd:int" cannot take "A" or complex types (mixed="false") cannot take simple text.

Another interesting point is that if we want to set the property value to be null, I think we should probably use xsi:nil="true" using the following styles:

5) <property name="prop1"><value xsi:nil="true"/></property> <!-- it requires the sca:value element to be nillable --> 6) <property name="prop1"><prop1 xsi:nil="true" xmlns":xsi="..."/></property> <!-- the propery is defined as a global element with nillable="true" -->

Ideally, the SCA spec should cover about all these situations to leave no space for ambiguity.

Thanks,
Raymond
[1] http://www.w3.org/TR/REC-xml/

Thanks,
Raymond
--------------------------------------------------
From: "Simon Laws" <[email protected]>
Sent: Monday, August 17, 2009 7:59 AM
To: "tuscany-dev" <[email protected]>
Subject: [2.x] property parsing question

I'm looking at otest ASM_4008 which is currently failing because the
test for no property value being specified is not good enough. Looking
at the code I find that I don't understand what some of it is trying
to do so it would be useful if someone in the know could explain. In
particular I'm interested in the operation of the code in

BaseAssemblyProcessor.readPropertyValue()

This is trying to read a property value from the input stream. It
seems that the propery.value model field is always represented as a
DOM with the following model

<property>
  <value>...</value>
</property>

The property element is fluffed up in a hard coded manner inside
readPropertyValue() and it then goes about trying to find property
values in various places, for example, by looking for an attribute
called "value".  There is some code toward the bottom of the operation
readPropertyValue() where it is starting to look at the value of the
property element itself.

       int event = reader.getEventType();
       while (true) {
           switch (event) {
               case START_ELEMENT:
                   name = reader.getName();
                   if (PROPERTY_QNAME.equals(name)) {
                       isTextForProperty = true;
                       break;
                   }
                   isTextForProperty = false;

Under what circumstances does input element ="property" in this case,
i.e. when does isTextForProperty  get set to true?

Regards

Simon

Reply via email to