I have to invoke a web service with a single parameter, a String in XML format. I'm building this via an XSLT transformation. So far so good.
The problem is with this XSD fragment:
<xs:complexType name="Document">
<xs:sequence>
<xs:element name="title" type="xs:string" minOccurs="1"/>
<xs:element name="content" type="xs:base64Binary" minOccurs="1"/>
</xs:sequence>
</xs:complexType>
which translates (for example) into this XML:
<attachment>
<title>test title</title>
<content>
PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Inllc
yI/Pg0KPG1zZ3ByYXRpY2E+DQogICAgPHByYXRpY2E+DQogICAgICAgIDxwcm9jZXNzbz
4NCiAgICAgICAgICAgIDxjb2RQcm9jZXNzbz4xPC9jb2RQcm9jZXNzbz4NCiAgICAgICA
gICAgIDxjb2RJc3RhbnphUHJvY2Vzc28MzwvY29kSXN0YW56YVByb2Nlc3NvPg0KICAgI
CAgICAgICAgPGNvZFN0YXRvPjYwPC9jb2RTdGF0bz4NCiAgICAgICAgPC9wcm9jZXNzbz
4NCiAgICA8L3ByYXRpY2E+DQo8L21zZ3ByYXRpY2E+
</content>
</attachment>
Yes, you got it right: I have to insert a file content into the XML document in base 64 binary format.
I thought about inserting a placeholder with XSLT and then processing the XML document to replace it with the actual file content, but I'm wondering if there are any best practices for these occasions, maybe some fancy XSTL trick well beyond my knowledge or some Java tools which may come in handy.
How would you do that?
NOTE: I can't use SOAP with attachment, and I'm well aware that the aforementioned approach is prone to failure in case of huge attachments, but at the moment our counterpart will not budge.