santuario-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Raul Benito" <>
Subject Re: signed xml does no more contain: <?xml version="1.0" encoding="UTF-8"?>
Date Wed, 15 Mar 2006 14:25:53 GMT
The C14n spec said clearly that c14n documents must not contain XML declaration.

extract from

4.1 No XML Declaration

The XML declaration, including version number and character encoding
is omitted from the canonical form. The encoding is not needed since
the canonical form is encoded in UTF-8. The version is not needed
since the absence of a version number unambiguously indicates XML 1.0.

Future versions of XML will be required to include an XML declaration
to indicate the version number. However, canonicalization method
described in this specification may not be applicable to future
versions of XML without some modifications. When canonicalization of a
new version of XML is required, this specification could be updated to
include the XML declaration as presumably the absence of the XML
declaration from the XPath data model can be remedied by that time
(e.g. by reissuing a new XPath based on the Infoset data model).


On 2/9/06, Fabio Mondelli <> wrote:
> Hello,
> I want to sign and verify xml files.
> in my case, the signed file does not contain the first line: <?xml
> version="1.0" encoding="UTF-8"?> from the original document.
> what could be the reason? Im doing a enveloped xml signature.
> here is the code:
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
>              dbf.setNamespaceAware(true);
>              DocumentBuilder db = dbf.newDocumentBuilder();
>              Document doc =
> db.parse(parameterObject.getUnsignedInputXMLFile());
>              String BaseURI =
> parameterObject.getSignedXMLFile().toURL().toString();
>              XMLSignature sig = new XMLSignature(doc, BaseURI,
> ...
>              Element rootElement = doc.getDocumentElement();
>              rootElement.insertBefore(sig.getElement(),
> rootElement.getFirstChild());
>              sig.addResourceResolver(new OfflineResolver());
>              Transforms transforms = new Transforms(doc);
> transforms.addTransform(Transforms.TRANSFORM_ENVELOPED_SIGNATURE);
> transforms.addTransform(Transforms.TRANSFORM_C14N_WITH_COMMENTS);
> thank U!


View raw message