Skip to Content.
Sympa Menu

mace-opensaml-users - OpenSAML 2.0 custom data type help

Subject: OpenSAML user discussion

List archive

OpenSAML 2.0 custom data type help


Chronological Thread 
  • From: Neill Miller <>
  • To:
  • Subject: OpenSAML 2.0 custom data type help
  • Date: Fri, 6 Feb 2009 11:59:10 -0600 (CST)

Hello,

I've implemented a custom datatype in OpenSAML2.0 (by following the docs and
the examples of the XS* types included in the library) and things mostly seem
to be working ok. I have a question about how I get the data into an
'AttributeValue' though. I can create the type and set the parameters as
expected with:

XSMyTypeBuilder mtb = new XSMyTypeBuilder();
XSMyType myTypeValue = mtb.buildObject(
XSMyType.DEFAULT_ELEMENT_NAME, XSMyType.TYPE_NAME);

myTypeValue.setParam1("foo");
myTypeValue.setParam2("bar");

// add to Attribute
// add to AttributeStatement, etc

However, when dumping the XML, I get the following format:

<saml:Attribute Name="MyAttribute" NameFormat="myType">
<myns:myType xmlns:myns="http://www.myns.org";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; param1="foo"
param2="bar" xsi:type="myns:myType"/>
</saml:Attribute>

What I (think I) want though is something like this:

<saml:Attribute Name="MyAttribute" NameFormat="myType">
<saml:AttributeValue xmlns:myns="http://www.myns.org";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="myns:myType">
<myns:myType param1="foo" param2="bar"/>
</saml:AttributeValue>
</saml:Attribute>

So I think I first need to do this:

XSMyType myTypeValue = mtb.buildObject(
AttributeValue.DEFAULT_ELEMENT_NAME, XSMyType.TYPE_NAME);

[ note use of AttributeValue's default element name, rather than myType's ]

I can get (very) close to the latter output by building that XML string in
the marshallElementContent method (and commenting out my marshallAttributes
method) of my marshaller, and adding it to the domElement there, but the
brackets get escaped in that case:

<saml:Attribute Name="MyAttribute" NameFormat="myType">
<saml:AttributeValue xmlns:myns="http://www.myns.org";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:type="myns:myType">
&lt;myns:myType param1="foo" param2="bar"/&gt;
</saml:AttributeValue>
</saml:Attribute>

That's likely because of the way the XMLHelper.appendTextContent is working.
Is there another method I can use that won't cause the escaping, or is there
a better XML output format I should be working toward to get this going?

thanks,
-Neill.



Archive powered by MHonArc 2.6.16.

Top of Page