Project

General

Profile

Actions

Bug #4942

closed

KarXmlGenerator generated a invalid kar xml if KarEntry has dependsOnModule element

Added by Jing Tao about 14 years ago. Updated about 14 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
core
Target version:
Start date:
04/16/2010
Due date:
% Done:

0%

Estimated time:
Bugzilla-Id:
4942

Description

When i tried to upload the tpc09-plant-dynamics-woody.kar to a remote server, kepler gets the error:
org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'dependsOnModule'. One of '{"":lsid}' is expected.

It seems the KarXmlGenerator generated a invalid kar xml.

However, if we upload some simple workflow such as, eml-simple-plot. it works fine.

Actions #1

Updated by Jing Tao about 14 years ago

I dug around and found the xml instance is:
<karEntryAttributes>
<Name>
tpc09-plant-dynamics-woody_ROML.xml
</Name>
<dependsOn>
urn:lsid:gamma.msi.ucsb.edu/OpenAuth/:8016:19:1
</dependsOn>
<handler>
org.kepler.kar.handlers.ReportLayoutKAREntryHandler
</handler>
<dependsOnModule>
reporting
</dependsOnModule>
<lsid>
urn:lsid:gamma.msi.ucsb.edu/OpenAuth/:3371:205:1
</lsid>
<type>
org.kepler.reporting.rio.ReportInstance
</type>
</karEntryAttributes>

The schema is:
<xs:complexType name="karEntryAttributesType">
<xs:sequence>
<xs:element name ="Name" type="xs:string" />
<xs:element name ="dependsOn" minOccurs="0" />
<xs:element name ="dependsOnModule" minOccurs="0" />
<xs:element name ="handler" />
<xs:element name ="lsid" />
<xs:element name ="type" />
</xs:sequence>
</xs:complexType>

Their orders are not match. So my question is: is the order of the schema correct?
If the schema is correct, we can change the code to create instance. Otherwise, we have to change the schema.

Actions #2

Updated by ben leinfelder about 14 years ago

whichever is less of a headache to change. we are in charge of both of them, so you might as well make it easy for yourself!

Actions #3

Updated by ben leinfelder about 14 years ago

Also - for WRP we are going to be adding more children to <karEntryAttributes> - ideally we'd like to add any element (as a string) since we are just transferring the manifest information to the XML.
it might be worthwhile to relax this element to allow as many child elements as we want for karEntryAttributes.
Or we could just wait for and change it when we get the WRP release ready

Actions #4

Updated by Jing Tao about 14 years ago

hrrm, this is a good point that wrp will add more elements there. I think the wrp will release soon. I don't want to upgrade the schema so frequently. We need to figure out the flexible way in the schema.

Actions #5

Updated by Jing Tao about 14 years ago

I dug code a little bit and found here is the code to generate the elements of karEntryAttribute:

Attributes atts = entry.getAttributes();

for (Object att : atts.keySet()) {

if (att instanceof Name) {
Name attrName = (Name) att;
String value = atts.getValue(attrName);
karxml.append(tab + tab + tab + "<" + attrName + ">" + nl);
karxml.append(tab + tab + tab + tab + value + nl);
karxml.append(tab + tab + tab + "</" + attrName + ">" + nl);

}

Attribute class extends from Map class. The Set object generated by atts.keySet() method doesn't have a fixed order. So the xml elements' order will vary too (this means that the xml instance could be invalid).

Actions #6

Updated by Jing Tao about 14 years ago

We will use a ordered key list (elements name) to get the value from the map. Then build the xml base on the element name and value. So the order of element will be same.

Actions #7

Updated by Sean Riddle about 14 years ago

Will this support the addition of more attributes in the future?

Actions #8

Updated by Jing Tao about 14 years ago

Sean: yes it will support new attributes too:

Ben, Aaron and I discussed the possibility to add some arbitrary elements to karEntryAttributes. We decided to modify the schema:
<xs:complexType name="karEntryType">
<xs:sequence>
<xs:element name="karEntryAttributes" type="karEntryAttributesType"/>
<xs:element name="karEntryXML" type="xs:anyType" />
</xs:sequence>
</xs:complexType>

<xs:complexType name="karEntryAttributesType">
<xs:sequence>
<xs:element name ="Name" type="xs:string" />
<xs:element name ="dependsOn" minOccurs="0" />
<xs:element name ="dependsOnModule" minOccurs="0" />
<xs:element name ="handler" />
<xs:element name ="lsid" />
<xs:element name ="type" />
<xs:element name="customAttribute" type="xs:anyType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

This schema still has some control on some elements (name, lsid and et al), it also has the flexibility to add arbitrary elements under element customAttribute.

If you have any objection, please let me know as soon as possible.

Actions #9

Updated by Jing Tao about 14 years ago

Here is an email from Aaron:

Hi Jing, I was thinking about this a bit and I think option 1 is the way to go. The KAREntryHandler mechanism allows any attribute
to be added to a KAREntry so the KARXML file will reflect that and should validate when it does. Since the required attributes like
lsid are enforced in the KARFile mechanism it is OK not to enforce it in the schema but we still need to allow any attribute to exist
there. A new KAREntryHandler that is developed with a new module may want to add an attribute that is not in the option 2 schema and
the developer shouldn't need to know about the customAttribute to add attributes to the Manifest (and by consequence the KARXML). So
I'd recommend option 1 for best compatibility if I'm understanding the schema correctly.

Aaron

Since Aaron is the person who is working on this part, i will go with option 1:

<xs:complexType name="karEntryType">
<xs:sequence>
<xs:element name="karEntryAttributes" type="xs:anyType"/>
<xs:element name="karEntryXML" type="xs:anyType" />
</xs:sequence>
</xs:complexType>

Actions #10

Updated by Jing Tao about 14 years ago

After changing the schema base on comment 9, the invalid error has gone.

Actions #11

Updated by Redmine Admin about 11 years ago

Original Bugzilla ID was 4942

Actions

Also available in: Atom PDF