本文整理汇总了C#中DocumentBuilder.Build方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentBuilder.Build方法的具体用法?C# DocumentBuilder.Build怎么用?C# DocumentBuilder.Build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DocumentBuilder
的用法示例。
在下文中一共展示了DocumentBuilder.Build方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: processTestSet
private void processTestSet(DocumentBuilder catbuilder, XPathCompiler xpc, XdmNode funcSetNode)
{
string testName;
try
{
results.WriteLine("<test-set name='" + funcSetNode.GetAttributeValue(new QName("name")) + "'>");
}
catch (Exception e)
{
}
string testSetFile = testSuiteDir + "\\" + funcSetNode.GetAttributeValue(new QName("file"));
xpc.BaseUri = testSetFile;
XdmNode testSetDocNode = catbuilder.Build(new Uri(testSetFile));
localEnvironments.Clear();
TestEnvironment defaultEnvironment = createLocalEnvironment(testSetDocNode.BaseUri);
localEnvironments.Add("default", defaultEnvironment);
bool run = true;
IEnumerator dependency = xpc.Evaluate("/test-set/dependency", testSetDocNode).GetEnumerator();
while (dependency.MoveNext())
{
if (!DependencyIsSatisfied((XdmNode)dependency.Current, defaultEnvironment))
{
run = false;
}
}
if (run)
{
IEnumerator iter = xpc.Evaluate("//environment[@name]", testSetDocNode).GetEnumerator();
while (iter.MoveNext())
{
processEnvironment(xpc, (XdmNode)iter.Current, localEnvironments);
}
IEnumerator testCases = xpc.Evaluate("//test-case", testSetDocNode).GetEnumerator();
while (testCases.MoveNext())
{
testName = ((XdmNode)xpc.EvaluateSingle("@name", (XdmItem)testCases.Current)).StringValue;
if (testPattern != null && !testPattern.Match(testName).Success)
{
continue;
}
feedback.Message("Test set " + funcSetNode.GetAttributeValue(new QName("name")) + " ", false);
runTestCase((XdmNode)testCases.Current, xpc);
}
}
try
{
results.WriteLine("</test-set>");
}
catch (Exception e)
{
}
}
示例2: buildSource
/**
* Construct source object. This method allows subclassing e.g. to build a DOM or XOM source.
* @param xml
* @return
* @throws XPathException
*/
protected XdmNode buildSource(XdmNode catalog, DocumentBuilder builder, String sourceName)
{
// Find the source element in the catalog
XPathSelector xps = findSourcePath.Load();
xps.SetVariable(new QName("", "param"), new XdmAtomicValue(sourceName));
xps.ContextItem = catalog;
XdmNode source = (XdmNode)xps.EvaluateSingle();
// decide whether schema validation is needed
bool validate = source.GetAttributeValue(new QName("", "schema")) != null;
if (validate)
{
builder.SchemaValidationMode = SchemaValidationMode.Strict;
}
else
{
builder.SchemaValidationMode = SchemaValidationMode.None;
}
// build the document tree from the source file
string filename = testSuiteDir + "/" + source.GetAttributeValue(new QName("", "FileName"));
if (source == null)
{
throw new ArgumentException("Source " + sourceName + " not found in catalog");
}
return builder.Build(new Uri(filename));
}
示例3: BuildDocument
private void BuildDocument(FileCollection files, Dictionary<string, object> metadata = null, ApplyTemplateSettings applyTemplateSettings = null, string templateFolder = null)
{
using (var builder = new DocumentBuilder(LoadAssemblies(), ImmutableArray<string>.Empty, null, templateFolder))
{
if (applyTemplateSettings == null)
{
applyTemplateSettings = new ApplyTemplateSettings(_inputFolder, _outputFolder);
applyTemplateSettings.RawModelExportSettings.Export = true;
}
var parameters = new DocumentBuildParameters
{
Files = files,
OutputBaseDir = Path.Combine(Directory.GetCurrentDirectory(), _outputFolder),
ApplyTemplateSettings = applyTemplateSettings,
Metadata = metadata?.ToImmutableDictionary(),
TemplateManager = new TemplateManager(null, null, new List<string> { _templateFolder }, null, null),
TemplateDir = templateFolder,
};
builder.Build(parameters);
}
}
示例4: buildSource
/**
* Construct source object. This method allows subclassing e.g. to build a DOM or XOM source.
* @param xml
* @return
* @throws XPathException
*/
protected XdmNode buildSource(DocumentBuilder builder, String xml, String validationMode)
{
if ("strict".Equals(validationMode))
{
builder.SchemaValidationMode = SchemaValidationMode.Strict;
}
else
{
builder.SchemaValidationMode = SchemaValidationMode.None;
}
return builder.Build(new Uri(xml));
}
示例5: BuildDocument
private void BuildDocument(
FileCollection files,
string inputFolder,
string outputFolder,
Dictionary<string, object> metadata = null,
ApplyTemplateSettings applyTemplateSettings = null,
string templateFolder = null,
string intermediateFolder = null,
Dictionary<string, ChangeKindWithDependency> changes = null)
{
using (var builder = new DocumentBuilder(LoadAssemblies(), ImmutableArray<string>.Empty, null, intermediateFolder))
{
if (applyTemplateSettings == null)
{
applyTemplateSettings = new ApplyTemplateSettings(inputFolder, outputFolder);
}
var parameters = new DocumentBuildParameters
{
Files = files,
OutputBaseDir = Path.Combine(Directory.GetCurrentDirectory(), outputFolder),
ApplyTemplateSettings = applyTemplateSettings,
Metadata = metadata?.ToImmutableDictionary(),
TemplateManager = new TemplateManager(null, null, new List<string> { templateFolder }, null, null),
TemplateDir = templateFolder,
Changes = changes?.ToImmutableDictionary(),
};
builder.Build(parameters);
}
}