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. XML / XSL
  4. Passing XmlResolver to Transform() method

Passing XmlResolver to Transform() method

Scheduled Pinned Locked Moved XML / XSL
xmlhtmlsysadminhelpquestion
3 Posts 2 Posters 0 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

    P 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

      P Offline
      P Offline
      Philip Fitzsimons
      wrote on last edited by
      #2

      you need to use a XPathNavigator: XslTransform xslt = new XslTransform(); XmlDocument formDocument = new XmlDocument(); sourceDocument.Load(sourceFileName); formDocument.Load(formFileName); xslt.Load(stylesheetFileName); MemoryStream ms = new MemoryStream(); **XPathNavigator nav = formDocument.CreateNavigator();** xslt.Transform(nav, null, ms, null); StreamReader sr = new StreamReader(ms); ms.Position = 0; string result = sr.ReadToEnd(); sr.Close();


      "When the only tool you have is a hammer, a sore thumb you will have."

      K 1 Reply Last reply
      0
      • P Philip Fitzsimons

        you need to use a XPathNavigator: XslTransform xslt = new XslTransform(); XmlDocument formDocument = new XmlDocument(); sourceDocument.Load(sourceFileName); formDocument.Load(formFileName); xslt.Load(stylesheetFileName); MemoryStream ms = new MemoryStream(); **XPathNavigator nav = formDocument.CreateNavigator();** xslt.Transform(nav, null, ms, null); StreamReader sr = new StreamReader(ms); ms.Position = 0; string result = sr.ReadToEnd(); sr.Close();


        "When the only tool you have is a hammer, a sore thumb you will have."

        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 had left this argument out and that is what generated the error. I still have no clue as to when or why to use a XmlResolver but found when I inserted a null for the arguemnt as it appears in your code 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