本文整理汇总了C#中System.Xml.XmlResolver类的典型用法代码示例。如果您正苦于以下问题:C# XmlResolver类的具体用法?C# XmlResolver怎么用?C# XmlResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlResolver类属于System.Xml命名空间,在下文中一共展示了XmlResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadXslt
/// <summary>
/// Loads the XSLT file using specified path, settings and stylesheet resolver.
/// </summary>
/// <param name="path">The URL to the XSLT file.</param>
/// <param name="settings">XSLT settings.</param>
/// <param name="stylesheetResolver">The stylesheet resolver.</param>
/// <returns><see cref="XslCompiledTransform" /> object that can transform the input.</returns>
public virtual XslCompiledTransform LoadXslt(string path, XsltSettings settings, XmlResolver stylesheetResolver)
{
var xslt = new XslCompiledTransform();
xslt.Load(path, settings, stylesheetResolver);
return xslt;
}
示例2: RecurseNode
private void RecurseNode(XmlDocument doc, XmlResolver resolver, XmlNode elementNode, string xsltName)
{
this.ElementToHTMLPage(doc,resolver,elementNode,xsltName);
foreach(XmlNode childNode in elementNode)
{
if(childNode.Name == "Glossary")
{
this.ElementToHTMLPage(doc,resolver,childNode,"Glossary.xsl");
}
if(childNode.Name == "Packages")
{
foreach(XmlNode packageNode in childNode.ChildNodes)
{
this.RecurseNode(doc,resolver,packageNode,"Package.xsl");
}
}
if(childNode.Name == "Actors")
{
foreach(XmlNode actorNode in childNode.ChildNodes)
{
this.RecurseNode(doc,resolver,actorNode,"Actor.xsl");
}
}
if(childNode.Name == "UseCases")
{
foreach(XmlNode useCaseNode in childNode.ChildNodes)
{
this.RecurseNode(doc,resolver,useCaseNode,"UseCase.xsl");
}
}
}
}
示例3: InitWriter
/// <summary>
/// Initializes the writer to write redirected output.
/// </summary>
/// <remarks>Depending on the <c>method</c> attribute value,
/// <c>XmlTextWriter</c> or <c>StreamWriter</c> is created.
/// <c>XmlTextWriter</c> is used for outputting XML and
/// <c>StreamWriter</c> - for plain text.
/// </remarks>
public void InitWriter(XmlResolver outResolver)
{
if (outResolver == null)
{
outResolver = new OutputResolver(Directory.GetCurrentDirectory());
}
// Save current directory
//storedDir = Directory.GetCurrentDirectory();
string outFile = outResolver.ResolveUri(null, href).LocalPath;
DirectoryInfo dir = Directory.GetParent(outFile);
if (!dir.Exists)
dir.Create();
// Create writer
if (method == OutputMethod.Xml)
{
xmlWriter = new XmlTextWriter(outFile, encoding);
if (indent)
xmlWriter.Formatting = Formatting.Indented;
if (!omitXmlDecl)
{
if (standalone)
xmlWriter.WriteStartDocument(true);
else
xmlWriter.WriteStartDocument();
}
}
else
textWriter = new StreamWriter(outFile, false, encoding);
// Set new current directory
//Directory.SetCurrentDirectory(dir.ToString());
href = ""; // clean the href for the next usage
}
示例4: CompileToType
public static CompilerErrorCollection CompileToType(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver, bool debug, TypeBuilder typeBuilder, string scriptAssemblyPath)
{
QilExpression expression;
if (stylesheet == null)
{
throw new ArgumentNullException("stylesheet");
}
if (typeBuilder == null)
{
throw new ArgumentNullException("typeBuilder");
}
if (settings == null)
{
settings = XsltSettings.Default;
}
if (settings.EnableScript && (scriptAssemblyPath == null))
{
throw new ArgumentNullException("scriptAssemblyPath");
}
if (scriptAssemblyPath != null)
{
scriptAssemblyPath = Path.GetFullPath(scriptAssemblyPath);
}
CompilerErrorCollection errors = new Compiler(settings, debug, scriptAssemblyPath).Compile(stylesheet, stylesheetResolver, out expression).Errors;
if (!errors.HasErrors)
{
if (GeneratedCodeCtor == null)
{
GeneratedCodeCtor = typeof(GeneratedCodeAttribute).GetConstructor(new Type[] { typeof(string), typeof(string) });
}
typeBuilder.SetCustomAttribute(new CustomAttributeBuilder(GeneratedCodeCtor, new object[] { typeof(XslCompiledTransform).FullName, "4.0.0.0" }));
new XmlILGenerator().Generate(expression, typeBuilder);
}
return errors;
}
示例5: XmlQueryContext
internal XmlQueryContext(XmlQueryRuntime runtime, object defaultDataSource, XmlResolver dataSources, XsltArgumentList argList, WhitespaceRuleLookup wsRules) {
this.runtime = runtime;
this.dataSources = dataSources;
this.dataSourceCache = new Hashtable();
this.argList = argList;
this.wsRules = wsRules;
if (defaultDataSource is XmlReader) {
this.readerSettings = new QueryReaderSettings((XmlReader) defaultDataSource);
}
else {
// Consider allowing users to set DefaultReaderSettings in XsltArgumentList
// readerSettings = argList.DefaultReaderSettings;
this.readerSettings = new QueryReaderSettings(new NameTable());
}
if (defaultDataSource is string) {
// Load the default document from a Uri
this.defaultDataSource = GetDataSource(defaultDataSource as string, null);
if (this.defaultDataSource == null)
throw new XslTransformException(Res.XmlIl_UnknownDocument, defaultDataSource as string);
}
else if (defaultDataSource != null) {
this.defaultDataSource = ConstructDocument(defaultDataSource, null, null);
}
}
示例6: XmlTransformingReader
/// <summary>
/// Creates XmlTransformingReader with given XmlReader, stylesheet URI,
/// XsltArgumentList and Xmlresolver.
/// </summary>
/// <param name="parentReader">Source XML as XmlReader</param>
/// <param name="transformSource">URI of the stylesheet to transform the source</param>
/// <param name="args">Arguments to the transformation</param>
/// <param name="resolver">XmlResolver to resolve URIs in document() function</param>
public XmlTransformingReader(XmlReader parentReader,
string transformSource, XsltArgumentList args, XmlResolver resolver)
{
XPathDocument doc = new XPathDocument(parentReader);
XslTransform xslt = new XslTransform();
xslt.Load(transformSource);
_outReader = xslt.Transform(doc, args, resolver);
}
示例7: NvdlValidatingReader
public NvdlValidatingReader (XmlReader reader, NvdlRules rules,
XmlResolver resolver, NvdlConfig config)
: base (reader)
{
dispatcher = new NvdlDispatcher (new SimpleRules (
new NvdlCompileContext (
rules, config, resolver)), this);
}
示例8: Execute
private void Execute(object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results)
{
if (dataSources == null)
{
dataSources = XmlNullResolver.Singleton;
}
this.delExec(new XmlQueryRuntime(this.staticData, defaultDocument, dataSources, argumentList, results));
}
示例9: XmlSecureResolver
public XmlSecureResolver (
XmlResolver resolver, Evidence evidence)
{
this.resolver = resolver;
if (SecurityManager.SecurityEnabled) {
this.permissionSet = SecurityManager.ResolvePolicy (evidence);
}
}
示例10: CanonicalXml
internal CanonicalXml(XmlDocument document, XmlResolver resolver, bool includeComments) {
if (document == null)
throw new ArgumentNullException("document");
m_c14nDoc = new CanonicalXmlDocument(true, includeComments);
m_c14nDoc.XmlResolver = resolver;
m_c14nDoc.Load(new XmlNodeReader(document));
m_ancMgr = new C14NAncestralNamespaceContextManager();
}
示例11: TransformToDocument
internal static XmlDocument TransformToDocument( XmlReader input, XslCompiledTransform transform, XsltArgumentList args, XmlResolver resolver )
{
XmlDocument doc = new XmlDocument( );
using( XmlWriter output = doc.CreateNavigator().AppendChild() )
{
transform.Transform( input, args, output, resolver );
}
return doc;
}
示例12: ExcCanonicalXml
internal ExcCanonicalXml(Stream inputStream, bool includeComments, string inclusiveNamespacesPrefixList, XmlResolver resolver, string strBaseUri) {
if (inputStream == null)
throw new ArgumentNullException("inputStream");
m_c14nDoc = new CanonicalXmlDocument(true, includeComments);
m_c14nDoc.XmlResolver = resolver;
m_c14nDoc.Load(Utils.PreProcessStreamInput(inputStream, resolver, strBaseUri));
m_ancMgr = new ExcAncestralNamespaceContextManager(inclusiveNamespacesPrefixList);
}
示例13: XmlOutput
internal XmlOutput(XslTransform transform, XsltArgumentList xsltArgs,
XPathNavigator navigator, XmlResolver resolverForXmlTransformed,
XmlReader[] readersToClose) {
_transform = transform;
_xsltArgs = xsltArgs;
_navigator = navigator;
_resolverForXmlTransformed = resolverForXmlTransformed;
_readersToClose = readersToClose;
}
示例14: ReadXml
public void ReadXml(XPathNavigator node, XmlResolver resolver)
{
if (node.NodeType == XPathNodeType.Element) {
if (node.MoveToFirstAttribute()) {
do {
switch (node.LocalName) {
case "media-type":
this.MediaType = node.Value;
break;
case "boundary":
this.Boundary = node.Value;
break;
}
} while (node.MoveToNextAttribute());
node.MoveToParent();
}
if (node.MoveToChild(XPathNodeType.Element)) {
XPathHttpMultipartItem currentItem = null;
do {
if (node.NamespaceURI == XPathHttpClient.Namespace) {
switch (node.LocalName) {
case "header":
if (currentItem == null) {
currentItem = new XPathHttpMultipartItem();
}
currentItem.Headers.Add(node.GetAttribute("name", ""), node.GetAttribute("value", ""));
break;
case "body":
if (currentItem == null) {
currentItem = new XPathHttpMultipartItem();
}
currentItem.Body = new XPathHttpBody();
currentItem.Body.ReadXml(node, resolver);
this.Items.Add(currentItem);
currentItem = null;
break;
}
}
} while (node.MoveToNext(XPathNodeType.Element));
node.MoveToParent();
}
}
}
示例15: CreateValidator
public override XmlReader CreateValidator (XmlReader reader,
XmlResolver resolver)
{
// XmlResolver is never used.
RelaxngValidatingReader rvr =
new RelaxngValidatingReader (
reader, pattern);
rvr.ReportDetails = true;
return rvr;
}