You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@santuario.apache.org by "Frank. Christopher" <C....@seeburger.de> on 2002/11/11 16:44:33 UTC

'Transform' with 'XPath'

Onk!

I am trying to add a XPath element to the XPATH transform but whatever I try, I get a "DOM005 Wrong document"  exception

This is what I try:

	//exclude SOAP 'Actor' from signature generation:
      Document doc= new DocumentImpl();
      Element xpathElem = doc.createElement("XPath");
      xpathElem.appendChild( doc.createTextNode("(xpath expression here)") );
	
	Transforms transforms = new Transforms(myDOMDocumentToSign);
	transforms.addTransform(Transforms.TRANSFORM_XPATH, xpathElem);
	>>>> will throw the exception.

Any idea?

Thx in advance.

Tot ziens
Atlana

P.S.: The XPath I try to add is:
" not (ancestor-or-self::node()[@SOAP:actor=&quot;urn:oasis:names:tc:ebxml-msg:actor:nextMSH&quot;] | ancestor-or-self::node()[@SOAP:actor=&quot;http://schemas.xmlsoap.org/soap/actor/next&quot;] )"



-- 
SEEBURGER AG, Edisonstrasse 1, D-75015 Bretten, Germany
Fon:+49(0)7252 96-1185 Fax:+49(0)7252 96-2400 <http://www.seeburger.de/>



Re: 'Transform' with 'XPath'

Posted by Christian Geuer-Pollmann <ge...@nue.et-inf.uni-siegen.de>.
Hi Frank,

you create an Element using doc and want to insert it into 
myDOMDocumentToSign. That's the problem. You must simply say

Element xpathElem = 
myDOMDocumentToSign.createElementNS(Constants.NamespaceSpexNS, "XPath");
xpathElem.appendChild( myDOMDocumentToSign.createTextNode("(xpath 
expression > here)"));

(Please note that the xpathElement MUST be created in the XMLSignature 
Namespace.)

BTW, you don't have to do this by hand. Use 
org.apache.xml.security.transforms.params.XPathContainer instead:

XPathContainer xpath = new XPathContainer(myDOMDocumentToSign);
xpath.setXPath("(xpath expression > here)");
Transforms transforms = new Transforms(myDOMDocumentToSign);
transforms.addTransform(Transforms.TRANSFORM_XPATH, xpath.getElement());

Christian

--On Montag, 11. November 2002 16:44 +0100 "Frank. Christopher" 
<C....@seeburger.de> wrote:

> Onk!
>
> I am trying to add a XPath element to the XPATH transform but whatever I
> try, I get a "DOM005 Wrong document"  exception
>
> This is what I try:
>
> 	//exclude SOAP 'Actor' from signature generation:
>       Document doc= new DocumentImpl();
>       Element xpathElem = doc.createElement("XPath");
>       xpathElem.appendChild( doc.createTextNode("(xpath expression
> here)") ); 	
> 	Transforms transforms = new Transforms(myDOMDocumentToSign);
> 	transforms.addTransform(Transforms.TRANSFORM_XPATH, xpathElem);
> 	>>>> will throw the exception.
>
> Any idea?
>
> Thx in advance.
>
> Tot ziens
> Atlana
>
> P.S.: The XPath I try to add is:
> " not
> (ancestor-or-self::node()[@SOAP:actor=&quot;urn:oasis:names:tc:ebxml-msg:
> actor:nextMSH&quot;] |
> ancestor-or-self::node()[@SOAP:actor=&quot;http://schemas.xmlsoap.org/soa
> p/actor/next&quot;] )"
>
>
>
> --
> SEEBURGER AG, Edisonstrasse 1, D-75015 Bretten, Germany
> Fon:+49(0)7252 96-1185 Fax:+49(0)7252 96-2400 <http://www.seeburger.de/>
>
>