本文整理汇总了C#中System.Xml.Xsl.XsltArgumentList.AddExtensionObject方法的典型用法代码示例。如果您正苦于以下问题:C# XsltArgumentList.AddExtensionObject方法的具体用法?C# XsltArgumentList.AddExtensionObject怎么用?C# XsltArgumentList.AddExtensionObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Xsl.XsltArgumentList
的用法示例。
在下文中一共展示了XsltArgumentList.AddExtensionObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Program
public Program()
{
//Set the UI to the specified culture.
Thread.CurrentThread.CurrentUICulture = new CultureInfo(_culturename);
//Create the XslTransform and load the stylesheet.
//XslTransform xslt = new XslTransform();
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(_stylesheet);
//Load the XML data file.
XPathDocument doc = new XPathDocument(_filename);
//Create an XsltArgumentList.
XsltArgumentList xslArg = new XsltArgumentList();
//Add an object to get the resources for the specified language.
ResourceTranslator resTran = new ResourceTranslator("Resources.Resource");
xslArg.AddExtensionObject("urn:myResTran", resTran);
//Add an object to calculate the circumference of the circle.
Calculate obj = new Calculate();
xslArg.AddExtensionObject("urn:myObj", obj);
//Create an XmlTextWriter to output to the console.
XmlTextWriter writer = new XmlTextWriter(Console.Out);
//Transform the file.
xslt.Transform(doc, xslArg, writer, null);
writer.Close();
}
示例2: Render
public void Render(object source, HtmlTextWriter htmlWriter, TemplateDefinition liveDefinition)
{
var resolver = new PathResolver(liveDefinition.Folder);
var hostPage = DNNContext.Current.Page;
var args = new XsltArgumentList();
args.AddExtensionObject("urn:ddrmenu", new XsltFunctions());
args.AddExtensionObject("urn:dnngarden", new XsltFunctions());
args.AddParam("ControlID", "", DNNContext.Current.HostControl.ClientID);
args.AddParam("Options", "", ConvertToJson(liveDefinition.ClientOptions));
args.AddParam("DNNPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Dnn)));
args.AddParam("ManifestPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Manifest)));
args.AddParam("PortalPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Portal)));
args.AddParam("SkinPath", "", hostPage.ResolveUrl(resolver.Resolve("/", PathResolver.RelativeTo.Skin)));
liveDefinition.TemplateArguments.ForEach(a => args.AddParam(a.Name, "", a.Value));
HttpContext.Current.Items["Resolver"] = resolver;
using (var xmlStream = new MemoryStream())
{
Utilities.SerialiserFor(source.GetType()).Serialize(xmlStream, source);
xmlStream.Seek(0, SeekOrigin.Begin);
xsl.Transform(XmlReader.Create(xmlStream), args, htmlWriter);
}
}
示例3: Transform
public void Transform(string inputFilePath, string outputFilePath, KeyValueConfigurationCollection settings)
{
var xsltTemplateReader = new XmlTextReader(inputFilePath);
var emptyDocumentReader = XmlReader.Create(new System.IO.StringReader("<empty />"));
var writerSettings = new XmlWriterSettings();
//settings.ConformanceLevel = ConformanceLevel.Fragment;
writerSettings.Indent = true;
using (var outputWriter = XmlWriter.Create(outputFilePath, writerSettings))
{
var xsltSettings = new XsltSettings();
XsltArgumentList argumentList = new XsltArgumentList();
var extensions = new XsltExtensionMethods(settings);
argumentList.AddExtensionObject("http://core.com/config", extensions);
argumentList.AddExtensionObject("http://setty.net/config", extensions);
var transformer = new XslCompiledTransform(true);
transformer.Load(xsltTemplateReader, xsltSettings, null);
transformer.Transform(emptyDocumentReader, argumentList, outputWriter);
}
}
示例4: Transform
public void Transform()
{
var xsltTemplateReader = new XmlTextReader(_xsltPath);
var emptyDocumentReader = XmlReader.Create(new System.IO.StringReader("<empty />"));
var settings = new XmlWriterSettings();
//settings.ConformanceLevel = ConformanceLevel.Fragment;
settings.Indent = true;
using (var outputWriter = XmlWriter.Create(_outputPath, settings))
{
var xsltSettings = new XsltSettings();
XsltArgumentList argumentList = new XsltArgumentList();
var extensions = new XsltExtensionMethods(_settings);
argumentList.AddExtensionObject("http://core.com/config", extensions);
argumentList.AddExtensionObject("http://paralect.com/config", extensions);
var transformer = new XslCompiledTransform(true);
transformer.Load(xsltTemplateReader, xsltSettings, null);
transformer.Transform(emptyDocumentReader,argumentList, outputWriter);
}
}
示例5: Init
public new void Init(object objParam)
{
// Get parameter info
_strPath = Path.Combine(@"TestFiles\", FilePathUtil.GetTestDataPath(), @"XsltApi\");
xsltArg1 = new XsltArgumentList();
MyObject obj1 = new MyObject(1, _output);
MyObject obj2 = new MyObject(2, _output);
MyObject obj3 = new MyObject(3, _output);
MyObject obj4 = new MyObject(4, _output);
MyObject obj5 = new MyObject(5, _output);
xsltArg1.AddExtensionObject("urn:my-obj1", obj1);
xsltArg1.AddExtensionObject("urn:my-obj2", obj2);
xsltArg1.AddExtensionObject("urn:my-obj3", obj3);
xsltArg1.AddExtensionObject("urn:my-obj4", obj4);
xsltArg1.AddExtensionObject("urn:my-obj5", obj5);
xsltArg1.AddParam("myArg1", szEmpty, "Test1");
xsltArg1.AddParam("myArg2", szEmpty, "Test2");
xsltArg1.AddParam("myArg3", szEmpty, "Test3");
xsltArg1.AddParam("myArg4", szEmpty, "Test4");
xsltArg1.AddParam("myArg5", szEmpty, "Test5");
return;
}
示例6: XsltTemplate
/// <summary>
/// 析构函数
/// </summary>
public XsltTemplate(_DbHelper c)
{
watch.Start();
conn = c;
_argList = new XsltArgumentList();
_argList.AddExtensionObject("roclog:function", new _ALFun(conn));
_argList.AddExtensionObject("sys:fun", new _ALFun(conn));
//扩展部分
foreach (object type in new SiteExpand().GetTypes(typeof(ITemplateFun).FullName))
{
ITemplateFun iae = ((ITemplateFun)type);
_argList.AddExtensionObject(string.Format("expand:{0}", iae.URI), iae);
}
}
示例7: LoadCategory
void LoadCategory()
{
if (base.XSLTemplateID > 0)
{
int ParentCategoryID = 0;
if (base.ContainerValue > 0)
{
ParentCategoryID = base.ContainerValue;
}
else
{
int.TryParse(Request.QueryString[CMSConfig.QueryString.CategoryID], out ParentCategoryID);
}
string categoryXML = CategoryManager.GetCategoryPublishXML(base.ModuleID, ParentCategoryID);
string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("CMS:UserControl", this);
xmlCategory.DocumentContent = categoryXML;
xmlCategory.TransformSource = xslPath;
xmlCategory.TransformArgumentList = arguments;
xmlCategory.DataBind();
}
}
示例8: CreateNuspecGraph
public static IGraph CreateNuspecGraph(XDocument nuspec, string baseAddress)
{
nuspec = NormalizeNuspecNamespace(nuspec);
XslCompiledTransform transform = CreateTransform("xslt.nuspec.xslt");
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddParam("base", "", baseAddress + "packages/");
arguments.AddParam("extension", "", ".json");
arguments.AddExtensionObject("urn:helper", new XsltHelper());
XDocument rdfxml = new XDocument();
using (XmlWriter writer = rdfxml.CreateWriter())
{
transform.Transform(nuspec.CreateReader(), arguments, writer);
}
RdfXmlParser rdfXmlParser = new RdfXmlParser();
XmlDocument doc = new XmlDocument();
doc.Load(rdfxml.CreateReader());
IGraph graph = new Graph();
rdfXmlParser.Load(graph, doc);
return graph;
}
示例9: Transform
public static string Transform(string xml,string xslFile)
{
XslTransform transform = new XslTransform();
XsltArgumentList args = new XsltArgumentList();
//define the xslt rendering file
//get the iterators for the root and context item
XPathDocument xmlDoc = new XPathDocument(new StringReader(xml));
XPathNavigator iter = xmlDoc.CreateNavigator();
//define and add the xslt extension classes
//Sitecore.Xml.Xsl.XslHelper sc = new Sitecore.Xml.Xsl.XslHelper();
XsltHelper xslt = new XsltHelper();
args.AddExtensionObject("http://www.rlmcore.vn/helper", xslt);
//add parameters
args.AddParam("item", "", iter);
args.AddParam("currentitem", "", iter.Select("."));
//define the stream which will contain the result of xslt transformation
//StringBuilder sb = new StringBuilder();
//TextWriter stream = new FileStream(new MemoryStream(Encoding.ASCII.GetBytes(sb.ToString())));
System.IO.StringWriter stream = new System.IO.StringWriter();
//load xslt rendering to XslTransform class
transform.Load(xslFile);
//perform a transformation with the rendering
transform.Transform(iter, args, stream);
return stream.ToString();
}
示例10: RenderRelatedNews
private void RenderRelatedNews()
{
if (Request.QueryString[ConstantsManager.NewsGUID] == null)
return;
//int _newsID = 0; Int32.TryParse(Request.QueryString[ConstantsManager.NewsID], out _newsID);
//if (_newsID == 0)
// return;
string guid = Request.QueryString[ConstantsManager.NewsGUID].ToString();
NewsItem _news = NewsItemManager.GetByGUID(guid);
if (null == _news)
return;
XmlDocument xDoc = NewsItemManager.GetNewsByKeywordAsXML(_news.Keywords, _news.ID);
if (null == xDoc)
return;
XslTemplate xslTemplate = XslTemplateManager.GetByID(XSLID);
if (null == xslTemplate)
return;
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("obj:CategoryViewer", this);
_news.Keywords = "";
_news.ViewCount++;
NewsItemManager.Update(_news);
string _html = UtilitiesManager.TransformXMLWithXSLText(xDoc.OuterXml, xslTemplate.Details, arguments);
dvData.InnerHtml = _html;
}
示例11: XTransformToWriter
public static void XTransformToWriter(this Linq.XElement xmlDoc, TextWriter writer,
Linq.XElement xmlXslt = null, // Action<XslCompiledTransform> onXsltLoad = null,
object xsltExtension = null,
string urn = "urn:request-info")
{
XslCompiledTransform trans = new XslCompiledTransform();
//if (onXsltLoad != null)
// onXsltLoad(trans);
//else
trans.Load(xmlXslt.CreateReader());
if (xsltExtension != null)
{
XsltArgumentList xslArg = new XsltArgumentList();
xslArg.AddExtensionObject(urn, xsltExtension);
// XTransformTo(trans, xmlDoc.CreateReader(), xslArg, writer);
// var results = writer;
XmlReader input = xmlDoc.CreateReader();
XmlWriterSettings outputSettings = trans.OutputSettings;
using (XmlWriter writerXml = XmlWriter.Create(writer, outputSettings))
{
trans.Transform(input, arguments: xslArg, results: writerXml,
documentResolver: XmlNullResolver.Singleton); // XsltConfigSection.CreateDefaultResolver());
writerXml.Close();
}
}
else
{
// trans.Transform(xmlDoc.CreateNavigator() as IXPathNavigable, arguments: null, results: writer);
XTransformTo(trans, xmlDoc.CreateReader(), null, writer);
}
}
示例12: LoadMenuItem
void LoadMenuItem()
{
int menuID = 0;
int.TryParse(Request.QueryString[CMSConfig.QueryString.MenuID], out menuID);
if (base.XSLTemplateID > 0 && menuID > 0)
{
string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("CMS:UserControl", this);
Menu menu = new Menu();
xmlMenu.DocumentContent = MenuManager.GetMenuItemTemplateXml(menuID, CMSContext.LanguageID, out menu);
xmlMenu.TransformSource = xslPath;
xmlMenu.TransformArgumentList = arguments;
xmlMenu.DataBind();
bool SetPageTitle = false;
bool.TryParse(this.Attributes["SetPageTitle"], out SetPageTitle);
if (SetPageTitle && menu != null)
{
this.Page.Title = menu.Name;
}
}
}
示例13: LoadGallery
void LoadGallery()
{
int CategoryId = 0;
CategoryId = base.ContainerValue;
if (CategoryId <= 0)
int.TryParse(Request.QueryString[CMSConfig.QueryString.CategoryID], out CategoryId);
if (base.XSLTemplateID > 0)
{
int PageSize = 10;
if (!string.IsNullOrEmpty(Attributes["PageSize"]))
{
PageSize = Convert.ToInt32(Attributes["PageSize"]);
}
int TotalCount = 0;
string galleryXML = GalleryManager.GetGallerysPublishXML(CategoryId, Core.Enums.CMSEnums.GalleryType.Photo, 1, PageSize, ref TotalCount);
string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("CMS:UserControl", this);
xmlGallery.DocumentContent = galleryXML;
xmlGallery.TransformSource = xslPath;
xmlGallery.TransformArgumentList = arguments;
xmlGallery.DataBind();
}
}
示例14: NewsViewer_UC_Load
void NewsViewer_UC_Load(object sender, EventArgs e)
{
if (Request.QueryString[ConstantsManager.MenuID] == null)
return;
int _menuID = 0;
Int32.TryParse(Request.QueryString[ConstantsManager.MenuID], out _menuID);
if (_menuID == 0)
return;
XmlDocument xDoc = MenuItemManager.GetByIDasXml(_menuID);
if (null == xDoc)
return;
XslTemplate xslTemplate = XslTemplateManager.GetByID(XSLID);
if (null == xslTemplate)
return;
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("obj:CategoryViewer", this);
string _html = UtilitiesManager.TransformXMLWithXSLText(xDoc.OuterXml, xslTemplate.Details, arguments);
dvData.InnerHtml = _html;
}
示例15: FillSitePath
private void FillSitePath()
{
int CatalogValue = -1;
if (!string.IsNullOrEmpty(CMSConfig.QueryString.CatalogID))
{
int.TryParse(Request.QueryString[CMSConfig.QueryString.CatalogID], out CatalogValue);
}
string xslPath = CMSWebHelper.GetXSLTemplateFilePath(base.XSLTemplateID);
xslPath = XSLTemplateManager.GetXSLTemplatePath(xslPath, base.XSLTemplateID);
XmlDocument xmlDoc = new XmlDocument();
XmlElement rootElement = xmlDoc.CreateElement("Root");
xmlDoc.AppendChild(rootElement);
if (CatalogValue > 0)
{
Catalog Catalog = CatalogManager.GetCatalog(CatalogValue, CMSContext.LanguageID);
if (Catalog != null)
{
FillCatalogsXML(Catalog, xmlDoc, rootElement);
XsltArgumentList arguments = new XsltArgumentList();
arguments.AddExtensionObject("CMS:UserControl", this);
xmlCatalog.DocumentContent = xmlDoc.OuterXml;
xmlCatalog.TransformSource = xslPath;
xmlCatalog.TransformArgumentList = arguments;
xmlCatalog.DataBind();
}
}
}