Skip to Content.
Sympa Menu

mace-opensaml-users - [OpenSAML] XMLTooling: How to set whiteSpace to preserve?

Subject: OpenSAML user discussion

List archive

[OpenSAML] XMLTooling: How to set whiteSpace to preserve?


Chronological Thread 
  • From: Hauke Mehrtens <>
  • To:
  • Subject: [OpenSAML] XMLTooling: How to set whiteSpace to preserve?
  • Date: Mon, 21 Mar 2011 16:33:30 +0100

We are using OpenSAML (2.2.3) and XMLTooling (1.2.0), using the latest
stable version is not a problem.

When generating some assertions the spaces at the end of a String are
removed and we need then there. The interesting part of the xml schema,
we are using to encode the assertions looks like this, changing the
schema is not an option.

<complexType name="GeneralDateType">
<sequence>
<element name="DateString">
<simpleType>
<restriction base="string">
<pattern value="[0-9 ]{8}" />
<whiteSpace value="preserve" />
</restriction>
</simpleType>
</element>
<element name="DateValue" type="date" minOccurs="0" />
</sequence>
</complexType>

A value like this: "200103 " is allowed and we have to set it with
spaces at the end.

Our current code for generating this DateString element looks like this:

XSAny child = new XSAnyBuilder().buildObject(new
QName("http://mydomain.de/namespace123/";, "DateString", "ipd"));
child.setTextContent("200103 ");

How do we set the <whiteSpace value="preserve" /> in XMLTooling? With
this code OpenSAML or XMLTooling removes the spaces at the end like the
XML spec says for normal XML Strings without any special whiteSpace element.

The resulting XML looks like this:

<saml2:AttributeValue
xmlns=\"http://www.w3.org/2001/XMLSchema-instance\";
xmlns:idp=\"http://mydomain.de/namespace123/\";
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\";
xsi:type=\"idp:GeneralDateType\"><idp:DateString>200103</idp:DateString></saml2:AttributeValue>

We want the xml to look like this:
<idp:DateString>200103 </idp:DateString>

How do we generate such an xml with OpenSAML and XMLTooling?

Hauke Mehrtens



Archive powered by MHonArc 2.6.16.

Top of Page