Hi Sudhi,

Appologize for the long email.

I downloaded the castor code and debugged my issue. By looking at the code,
I have created one more failure scenario/bug?

Here is a sample mapping file:
<mapping 
        xmlns="http://castor.exolab.org/";
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
        
        <class
name="com.schwab.sim.fw.services.security.authorization.ws.AuthzDecisionQuer
y">
                <map-to xml="samlp:AuthzDecisionQuery"/>

                <field name="subjectNameFormat" 
                        get-method="getSubjectNameFormat" 
                        set-method="setSubjectNameFormat" 
                        type="java.lang.String">
                        <bind-xml name="saml:Format" node="attribute"
location="Subject/NameID"/>
                </field>
                
                <field name="sessionIndex" 
                        get-method="getSessionIndex" 
                        set-method="setSessionIndex" 
                        type="java.lang.String">
                        <bind-xml name="saml:SessionIndex" node="attribute"
location="Subject"/>
                </field>
                
        </class>
</mapping>

The above mapping file creates following XML:
<samlp:AuthzDecisionQuery
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">  
        <Subject saml:SessionIndex="1234567890">
                <NameID
saml:Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" /> 
        </Subject>
</samlp:AuthzDecisionQuery>

All good so far. Now reverse the order of field mapping as below:

<mapping 
        xmlns="http://castor.exolab.org/";
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
        
        <class
name="com.schwab.sim.fw.services.security.authorization.ws.AuthzDecisionQuer
y">
                <map-to xml="samlp:AuthzDecisionQuery"/>

                <field name="sessionIndex" 
                        get-method="getSessionIndex" 
                        set-method="setSessionIndex" 
                        type="java.lang.String">
                        <bind-xml name="saml:SessionIndex" node="attribute"
location="Subject"/>
                </field>

                <field name="subjectNameFormat" 
                        get-method="getSubjectNameFormat" 
                        set-method="setSubjectNameFormat" 
                        type="java.lang.String">
                        <bind-xml name="saml:Format" node="attribute"
location="Subject/NameID"/>
                </field>
                                
        </class>
</mapping>

And output would look as below:
<samlp:AuthzDecisionQuery
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
        xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
        xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">  
        <Subject saml:SessionIndex="1234567890"/>
        <Subject>
                <NameID
saml:Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" /> 
        </Subject>
</samlp:AuthzDecisionQuery>

Happy debugging!!!
-Kiran

-----Original Message-----
From: Sudhendra Seshachala [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 18, 2004 12:21 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] [XML] Marshall attribute


I thing A is like a container class and in his hierarchy of classes, he does
need A to contain B. Is this correct Kiran?

Thanks
Sudhi
-----Original Message-----
From: Avinash Gangadharan [mailto:[EMAIL PROTECTED] 
Sent: Friday, June 18, 2004 12:11 PM
To: '[EMAIL PROTECTED]'
Subject: Re: [castor-user] [XML] Marshall attribute


Your Question :
 
       I have two classes:
                public class A {
                     public B url= new B();
                     public B getUrl() {return url}
                     public void setUrl(B b) { url = b; }

                }
                public class B {
                      public String url = "";
                      public String fixedAtt = "aaa";
               }
You want :
        <url att="aaa">bbb</url>      

Now what is "bbb", where is it going to come from. 

Secondly why do you have Class A which contains nothing but class B and
nothing else. Do you have any other properites in class A other than class
B. If all you want is the output : <url att="aaa">bbb</url> Get rid of class
A. And assuming "bbb" is the "url" property of class B. Heres how your
mapping should look like.

<class name="B">
                <map-to xml="url"/>
                <field name="fixedAtt" type="java.lang.String"
direct="true">
                        <bind-xml name="att" node="attribute"/>
                </field>
                <field name="url" type="java.lang.String" direct="true">
                        <bind-xml name="PCDATA" node="text"/>
                </field>
</class>

If I misunderstood your question please clarify.

HTH
Avinash

-----Original Message-----
From: Gawde, Kiran [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 17, 2004 5:50 PM
To: '[EMAIL PROTECTED]'
Subject: Re: [castor-user] [XML] Marshall attribute



Hi Sudhi,

node="text" adds it to url and ignores name="foo". See output below:
<url>bbb
        <foo att="aaa" />
</url>

This is the same issue as I mentioned before. For now, I have commented out
that mapping, as it causes exception on the client side which tries to parse
the xml. Waiting for the fix.

Regards,
Kiran

-----Original Message-----
From: Sudhendra Seshachala [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 17, 2004 5:33 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] [XML] Marshall attribute


Have u tried the following..

<class name="A">
  <field name="url" type="B" />            
</class>

<class name="B>
  <field name="fixedAtt" type="string">
     <bind-xml name="att" node="attribute" location="foo"/>
  </field>

  <field name="value" type="string">
     <bind-xml name="foo" node="text"/>
  </field>

<class>
Or is it related to location attribute issue you had before?

Thanks
Sudhi

-----Original Message-----
From: Gawde, Kiran [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 17, 2004 5:22 PM
To: '[EMAIL PROTECTED]'
Subject: Re: [castor-user] [XML] Marshall attribute


Hi Sudhi,

Just a note on the related issue.
If you add a location attribute for the fields in the sample below it
doesn't work as expected: <class name="A">
  <field name="url" type="B" />            
</class>
<class name="B>
  <field name="fixedAtt" type="string">
     <bind-xml name="att" node="attribute" location="foo"/>
  </field>
  <field name="value" type="string">
     <bind-xml name="att" node="text" location="foo"/>
  </field>
<class>

Expected result would be:
<url>
        <foo att="aaa">bbb</foo>
</url>

But instead you would get:
<url>bbb
        <foo att="aaa" />
</url>

Regards,
Kiran

-----Original Message-----
From: Sudhendra Seshachala [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 17, 2004 11:26 AM
To: [EMAIL PROTECTED]
Subject: Re: [castor-user] [XML] Marshall attribute


Check the mapping as below..
<class name="A">
                          <field name="url" type="B" />             

                  </class> 
                   
                  <class name="B>
                          <field name="fixedAtt" type="string">
                             <bind-xml name="att" node="attribute"/>
                          </field>
                          <field name="value" type="string">
                             <bind-xml name="att" node="text"/>
                          </field>
                   <class>
-----Original Message-----
From: Cristian [mailto:[EMAIL PROTECTED] 
Sent: Thursday, June 17, 2004 11:19 AM
To: [EMAIL PROTECTED]
Subject: [castor-user] [XML] Marshall attribute


Hi all

I have a simple question, I think: 

       I want to marshall an xml file with this format:


           <root>   
                <url att="aaa">bbb</url>
            </root>

      The attribute value (aaa) is fixed.
  
       I have two classes:

                public class A {
                     public B url= new B();

                     public B getUrl() {return url}
                     public void setUrl(B b) { url = b; }
                      
                    }

                 public class B {
                      public String url = "";
                      public String fixedAtt = "aaa";
                  }
      
          And my mapping file look like this:
                 <class name="A">
                          <field name="url" type="B" />             

                  </class> 
                   
                  <class name="B>
                          <field name="fixedAtt" type="string">
                             <bind-xml name="att" node="attribute"/>
                          </field>
                   <class>


          When I execute my code, the result look like:
       
                   <url att="aaa" />

          but I want something like:
                 <url att="aaa">Something</url>

          It's that possible ?

          Thanks..



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to