Click or drag to resize

C14nToFile Method

Performs C14N transformation of XML document (file-to-file).

Namespace: Sc14n
Assembly: diSc14nNet (in diSc14nNet.dll) Version: 3.1.0.28355 (3.1.0.0)
Syntax
public static int ToFile(
	string outFile,
	string xmlFile,
	string nameOrId = "",
	Tran tranOpt = Tran.Entire,
	TranMethod tranMethod = TranMethod.Inclusive,
	string exclParams = "",
	AdvOptions advOpts = AdvOptions.Default
)

Parameters

outFile  String
Name of output file to create.
xmlFile  String
Name of input XML file.
nameOrId  String  (Optional)
Tag name or Id to include or omit [optional, default=""] (see remarks below).
tranOpt  Tran  (Optional)
Transformation option [optional, default=Tran.Entire].
tranMethod  TranMethod  (Optional)
Transformation method [optional, default=TranMethod.Inclusive].
exclParams  String  (Optional)
InclusiveNamespaces PrefixList parameter for exclusive c14n [optional, default=""].
advOpts  AdvOptions  (Optional)
Option flags [optional, default=0].

Return Value

Int32
0 if successful or non-zero error code.
Remarks
Use the nameOrId parameter to specify the element of the XML document to include or omit.

With options OmitByTag or SubsetByTag, nameOrId specifies the element's tag name.

  • By default, the first element with a matching tag name will be chosen.
  • To specify the Nth element, write as tagname[N] where N=1,2,3,...
With options OmitById or SubsetById, nameOrId specifies the element's Id.
  • The default Id attribute name is Id, so the argument myvalue will find the element with attribute Id="myvalue".
  • To use a different attribute name - for example ID - write in the form ID=myvalue with no quotes.
With option Entire, the parameter is ignored, so just use "" or null.

Exactly one element will be omitted or included. Tag names and Id values are case sensitive. It is an error (NO_DATA_ERROR) if no matching element is found.

Example
C#
// Example 1. Omits the first element with the tag name <Signature>
r = C14n.ToFile("c14nfile1.txt", "input.xml", "Signature", Tran.OmitByTag);

// Example 2. Finds and transforms the first element with the tag name <SignedInfo>
r = C14n.ToFile("c14nfile2.txt", "input.xml", "SignedInfo", Tran.SubsetByTag);

// Example 3. Finds and transforms the third element with the tag name <Data>
r = C14n.ToFile("c14nfile3.txt", "input.xml", "Data[3]", Tran.SubsetByTag);

// Example 4. Finds and transforms the element with attribute Id="foo"
r = C14n.ToFile("c14nfile4.txt", "input.xml", "foo", Tran.SubsetById);

// Example 5. Finds and transforms the element with attribute ID="bar"
r = C14n.ToFile("c14nfile5.txt", "input.xml", "ID=bar", Tran.SubsetById);

// Example 6. Omits element with attribute Id="thesig"
r = C14n.ToFile("c14nfile6.txt", "input.xml", "thesig", Tran.OmitById);
See Also