Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Passing XmlResolver to Transform() method

Passing XmlResolver to Transform() method

Scheduled Pinned Locked Moved C#
xmlhtmlsysadminhelpquestion
3 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    kyledunn
    wrote on last edited by
    #1

    Hi, I have a method to render HTML from XSLT. Here is the method: /// /// Method that renders HTML from XSLT document /// /// protected override void Render(HtmlTextWriter writer) { XPathDocument xdoc = new XPathDocument(Context.Server.MapPath(sourceFilePath)); XslTransform xslt = new XslTransform(); xslt.Load(Context.Server.MapPath(transformFilePath)); xslt.Transform(xdoc, null, writer); } I am now getting this warning: warning CS0618: 'System.Xml.Xsl.XslTransform.Transform(System.Xml.XPath.IXPathNavigable, System.Xml.Xsl.XsltArgumentList, System.IO.TextWriter)' is obsolete: 'You should pass XmlResolver to Transform() method' I need some help resolving this warning. Can you help? Kyle

    N 1 Reply Last reply
    0
    • K kyledunn

      Hi, I have a method to render HTML from XSLT. Here is the method: /// /// Method that renders HTML from XSLT document /// /// protected override void Render(HtmlTextWriter writer) { XPathDocument xdoc = new XPathDocument(Context.Server.MapPath(sourceFilePath)); XslTransform xslt = new XslTransform(); xslt.Load(Context.Server.MapPath(transformFilePath)); xslt.Transform(xdoc, null, writer); } I am now getting this warning: warning CS0618: 'System.Xml.Xsl.XslTransform.Transform(System.Xml.XPath.IXPathNavigable, System.Xml.Xsl.XsltArgumentList, System.IO.TextWriter)' is obsolete: 'You should pass XmlResolver to Transform() method' I need some help resolving this warning. Can you help? Kyle

      N Offline
      N Offline
      Nick Parker
      wrote on last edited by
      #2

      kyledunn wrote: I need some help resolving this warning. Can you help? Try this:

      protected override void Render(HtmlTextWriter writer)
      {
      XmlDocument xdoc = new XmlDocument();
      xdoc.Load(Context.Server.MapPath(sourceFilePath));
      XPathNavigator nav = xdoc.CreateNavigator();
      XslTransform xslt = new XslTransform();
      xslt.Load(Context.Server.MapPath(transformFilePath));
      xslt.Transform(nav, null, writer);
      }

      -Nick Parker

      K 1 Reply Last reply
      0
      • N Nick Parker

        kyledunn wrote: I need some help resolving this warning. Can you help? Try this:

        protected override void Render(HtmlTextWriter writer)
        {
        XmlDocument xdoc = new XmlDocument();
        xdoc.Load(Context.Server.MapPath(sourceFilePath));
        XPathNavigator nav = xdoc.CreateNavigator();
        XslTransform xslt = new XslTransform();
        xslt.Load(Context.Server.MapPath(transformFilePath));
        xslt.Transform(nav, null, writer);
        }

        -Nick Parker

        K Offline
        K Offline
        kyledunn
        wrote on last edited by
        #3

        Thank you Nick! I did need to use an XPathNavigator but even then the error message about using XmlResolver still appeared. Upon further research I found that XmlResolver is a argument in the Transform method. Transform(XPathNavigator, XsltArgumentList, TextWriter, XmlResolver); I still have no clue as to when or why to use a XmlResolver but found when I inserted a null for the arguemnt that the error disappeared. Transform(nav,null,writer,null); I suspect you can create custom resolvers to influence the Transform but that's for another day. Problem solved. Thank you. Kyle

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups