Discuss this help topic in SecureBlackbox Forum

XML: Add XPath Filter 2.0 transform to reference

TElXMLXPathFilter2Transform class represents the XPath Filter 2.0 transform for an XML digital signature as defined by the XML-DSig standard.

To add XPath Filter 2.0 transform to the reference transform chain you need to

  1. create an instance of TElXMLXPathFilter2Transform class;
  2. create an instance of TElXMLXPathFilterItem class for each item of the transform;
  3. set XPath expression of each filter item instance and define prefixes used in expression;
  4. add the transform to the chain

C#:


TElXMLReference Ref = new TElXMLReference();
TElXMLXPathFilter2Transform XPathFilterTransform = new TElXMLXPathFilter2Transform();
TElXMLXPathFilterItem FilterItem = new TElXMLXPathFilterItem();
FilterItem.Filter = SBXMLTransform.Unit.xfSubtract;
FilterItem.NamespaceMap.AddNamespace("ds", "http://www.w3.org/2000/09/xmldsig#");
FilterItem.XPath = "//ds:Signature";
XPathFilterTransform.Add(FilterItem);
Ref.TransformChain.Add(XPathFilterTransform);
Delphi:

var
  Ref : TElXMLReference;
  XPathFilterTransform : TElXMLXPathFilter2Transform;
  FilterItem : TElXMLXPathFilterItem;
...
Ref := TElXMLReference.Create;
XPathFilterTransform := TElXMLXPathFilter2Transform.Create();
FilterItem := TElXMLXPathFilterItem.Create();
FilterItem.Filter := xfSubtract;
FilterItem.NamespaceMap.AddNamespace('ds', 'http://www.w3.org/2000/09/xmldsig#');
FilterItem.XPath := '//ds:Signature';
XPathFilterTransform.Add(FilterItem);
Ref.TransformChain.Add(XPathFilterTransform);

How To articles about XML signing (XMLDSig and XAdES)

Discuss this help topic in SecureBlackbox Forum