Aldrin,

can you please create a new Jira issue at

http://jira.codehaus.org/browse/CASTOR

and attach all files. With regards to the marshalling issue, I think a very similar issue has been created recently. Can you please have a llok ?

Regards
Werner

aldrin d'souza wrote:
Hello Werner,
Thanks for your response. I turned the type mode back to 'element'. However, it still didn't work for me. The issue seems to be with the handling of a sequence of subsitution group elements. XACMLClassDescriptorImpl:339 throws a ValidationException stating: Element with name -subtype- passed to type -container- in incorrect order; It is not allowed to be the last element of this sequence! Here's a minimal XSD you asked for:
-------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xacml="urn:oasis:names:tc:xacml:2.0:policy:schema:os" xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema>" targetNamespace="urn:oasis:names:tc:xacml:2.0:policy:schema:os" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xs:element name="Expression" type="xacml:ExpressionType" abstract="true"/>
  <xs:complexType name="ExpressionType" abstract="true"/>
  <xs:element name="Condition" type="xacml:ConditionType"/>
  <xs:complexType name="ConditionType">
    <xs:sequence>
      <xs:element ref="xacml:Expression"/>
    </xs:sequence>
  </xs:complexType>
<xs:element name="Apply" type="xacml:ApplyType" substitutionGroup="xacml:Expression"/>
  <xs:complexType name="ApplyType">
    <xs:complexContent>
      <xs:extension base="xacml:ExpressionType">
        <xs:sequence>
<xs:element ref="xacml:Expression" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="FunctionId" type="xs:anyURI" use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>
-------------
Here's an input document: --------------
<Condition  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
            xmlns='urn:oasis:names:tc:xacml:2.0:policy:schema:os'
xsi:schemaLocation='urn:oasis:names:tc:xacml: 2.0:policy:schema:os minimal.xsd'>
  <Apply
FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of">
  <Apply
    FunctionId="urn:oasis:names:tc:xacml: 1.0:function:string-bag"/>
    <Apply
    FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag"/>
    </Apply>
</Condition>
--------------
Here's the exception trace I get: -------------- Caused by: ValidationException: Element with name Apply passed to type Condition in incorrect order; It is not allowed to be the last element of this sequence! at org.exolab.castor.xml.util.XMLClassDescriptorImpl.checkDescriptorForCorrectOrderWithinSequence (XMLClassDescriptorImpl.java:339) at org.exolab.castor.xml.MarshalFramework$InternalXMLClassDescriptor.checkDescriptorForCorrectOrderWithinSequence(MarshalFramework.java:652) at org.exolab.castor.xml.UnmarshalHandler.startElement (UnmarshalHandler.java:1870) at org.exolab.castor.xml.UnmarshalHandler.startElement(UnmarshalHandler.java:1353) at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source) at org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch (Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source) at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
        at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
        at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at org.exolab.castor.xml.Unmarshaller.unmarshal (Unmarshaller.java:709) at org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:610)
        at ajd.condition.Minimal.main(Minimal.java:38)
---------------------
To work around, I'm currently setting the "org.exolab.castor.xml.lenient.sequence.order" property to true at runtime. With this property, I can unmarshal my document. However, I'm not sure if that's the best way to proceed. Another problem is the way substitution types are marshalled. For instance, after unmarshalling, if I marshal the input document again, this is what I get: ----
<Condition xmlns="urn:oasis:names:tc:xacml:2.0:policy:schema:os">
    <Expression xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance "
FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-at-least-one-member-of" xsi:type="Apply">
        <Expression
FunctionId="urn:oasis:names:tc:xacml: 1.0:function:string-bag" xsi:type="Apply"/>
        <Expression
FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag" xsi:type="Apply"/>
    </Expression>
</Condition>
-----
This isn't the same as the input. How do I get back the original document? Finally, I really appreciate your efforts for looking into this issue. Thanks again. thanks,
--
ajd.
On 19/12/2007, *Werner Guttmann* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Btw, I just noticed (re-reading parts of your  message again) that you
    are using 'type' mode during code generation. As far as I remember,
    that
    will not work with substitution groups, but I am not 100% sure. Can you
    please switch to 'element' mode and see whetehr that makes a
    difference ?

    Thanks in advance
    Werner

    aldrin d'souza wrote:
     > Hello,
     >
     > I'm facing a problem which has been discussed on this mailing
    list before -
     >
    http://www.mail-archive.com/[email protected]/msg04355.html
    <http://www.mail-archive.com/[email protected]/msg04355.html>
     >
     > Here is the the issue:
     >
     > I am using castor 1.1.2.1 <http://1.1.2.1/> <http://1.1.2.1
    <http://1.1.2.1/>> to generate the java classes
     > that correspond to the XACML 2.0 XSD which makes use of
    substitution groups.
     > An element "Apply" can appear wherever an element "Expression" is
     > expected. Based on the schema the following is a valid document:
     >
     > ---------------------------------------------------
     > <PolicySet  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
     >             xmlns='urn:oasis:names:tc:xacml: 2.0:policy:schema:os'
     >
     > xsi:schemaLocation='urn:oasis:names:tc:xacml:2.0:policy:schema:os
     >
    
http://docs.oasis-open.org/xacml/access_control-xacml-2.0-policy-schema-os.xsd
    
<http://docs.oasis-open.org/xacml/access_control-xacml-2.0-policy-schema-os.xsd>
     > <
    
http://docs.oasis-open.org/xacml/access_control-xacml-2.0-policy-schema-os.xsd>'
     >             PolicySetId="policy-set"
     >
     >
    
PolicyCombiningAlgId="urn:oasis:names:tc:xacml:1.0:policy-combining-algorithm:deny-overrides
    ">
     >   <Target/>
     >   <Policy PolicyId="policy"
     > RuleCombiningAlgId="urn:oasis:names:tc:xacml:
     > 1.0:rule-combining-algorithm:first-applicable">
     >     <Target/>
     >     <Rule RuleId="primary-rule" Effect="Permit">
     >       <Condition>
     >         <Apply
     >           FunctionId="urn:oasis:names:tc:xacml:
     > 1.0:function:string-at-least-one-member-of ">
     >           <Apply
> FunctionId="urn:oasis:names:tc:xacml:1.0:function:string-bag ">
     >             <AttributeValue
     >               DataType=" http://www.w3.org/2001/XMLSchema#string";>
     >               Admin
     >             </AttributeValue>
     >             <AttributeValue
     >               DataType=" http://www.w3.org/2001/XMLSchema#string";>
     >               Operator
     >             </AttributeValue>
     >           </Apply>
     >           <SubjectAttributeDesignator
     >             AttributeId="urn:oasis:names:tc:xacml: 2.0:subject:role"
     >             DataType="http://www.w3.org/2001/XMLSchema#string "
     >             SubjectCategory="urn:oasis:names:tc:xacml:
     > 1.0:subject-category:access-subject" />
     >         </Apply>
     >       </Condition>
     >     </Rule>
     >   </Policy>
     > </PolicySet>
     > -------------------------------------
     >
     > However, when I try to unmarshal it - the code fails with the
    following
     > exception:
     >
     > -------------------------------------
     > org.exolab.castor.xml.MarshalException: unable to find
    FieldDescriptor
     > for 'Apply' in ClassDescriptor of ConditionType
     > -------------------------------------
     >
     > Apparently, the unmarshalling code does not seem to understand the
     > substitution group.
     > Based on the suggestions I found on the web I enabled the following
     > options in my castorbuilder.properties file:
     >
     > -------------------------------------
     > org.exolab.castor.builder.automaticConflictResolution=true
     > org.exolab.castor.builder.javaclassmapping=type
     > -------------------------------------
     >
     > However, it still doesn't work.
     > Any help on this would be appreciated.
     >
     > thanks,
     > --
     > ajd.
     >



---------------------------------------------------------------------
To unsubscribe from this list please visit:

   http://xircles.codehaus.org/manage_email

Reply via email to