Re: [xml] question about how to set namespace in libxml
- From: Daniel Veillard <veillard redhat com>
- To: Liam R E Quin <liam holoweb net>
- Cc: xml gnome org
- Subject: Re: [xml] question about how to set namespace in libxml
- Date: Sun, 6 Mar 2011 13:36:54 +0800
On Sat, Mar 05, 2011 at 12:16:50PM -0500, Liam R E Quin wrote:
On Sat, 2011-03-05 at 14:52 +0100, Michael Ludwig wrote:
Dan Quach schrieb am 01.03.2011 um 12:05 (-0800):
Currently I am reading in the following xml document (through a ruby
wrapper)
LibXML::XML::Document.string( saml_plain)
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm='
http://www.w3.org/2001/10/xml-exc-c14n#'/>
[â]
</ds:SignedInfo>
That document is not namespace-well-formed.
<wrapper xmlns:ds="http://www.example.org/ds/">
<ds:SignedInfo>
<ds:CanonicalizationMethod
Algorithm='http://www.w3.org/2001/10/xml-exc-c14n#'/>
</ds:SignedInfo>
</wrapper>
might be one way to handle it.
Another way which requires only modificating the beginning is to
push an internal subset first with a defaulted xmlns:ds on the top
element, the advantage would be that the tree don't need to be modified
there after (well maybe except dropping the DTD).
paphio:~/XML -> cat tst.xml
<!DOCTYPE ds:SignedInfo [
<!ATTLIST ds:SignedInfo
xmlns:ds CDATA #FIXED 'foo'>
]>
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm='
http://www.w3.org/2001/10/xml-exc-c14n#'/>
<ds:SignatureMethod
Algorithm='http://www.w3.org/2000/09/xmldsig#rsa-sha1'/>
<ds:Reference URI='#FYQBldG6i_i18gy6gJfhOh7.u_T'>
<ds:Transforms>
<ds:Transform Algorithm='
http://www.w3.org/2000/09/xmldsig#enveloped-signature'/>
<ds:Transform Algorithm='http://www.w3.org/2001/10/xml-exc-c14n#'/>
</ds:Transforms>
<ds:DigestMethod Algorithm='http://www.w3.org/2000/09/xmldsig#sha1'/>
<ds:DigestValue>KpuhfX2q6nR660VW/dS0vIrVtSg=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
paphio:~/XML -> ./xmllint tst.xml
<?xml version="1.0"?>
<!DOCTYPE ds:SignedInfo [
<!ATTLIST ds:SignedInfo xmlns:ds CDATA #FIXED "foo">
]>
<ds:SignedInfo xmlns:ds="foo">
<ds:CanonicalizationMethod Algorithm="
http://www.w3.org/2001/10/xml-exc-c14n#"/>
<ds:SignatureMethod
Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<ds:Reference URI="#FYQBldG6i_i18gy6gJfhOh7.u_T">
<ds:Transforms>
<ds:Transform Algorithm="
http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>KpuhfX2q6nR660VW/dS0vIrVtSg=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
paphio:~/XML ->
Seems to work here :-)
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel veillard com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]