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. read and edit xsl in c#

read and edit xsl in c#

Scheduled Pinned Locked Moved C#
csharpxmltutorialquestion
6 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.
  • I Offline
    I Offline
    Inam
    wrote on last edited by
    #1

    I want to ask that how can i read, edit and write a xsl file. what classes i have to use. please guide me a little Thanx in advance Regards minamkhan Inam

    H 1 Reply Last reply
    0
    • I Inam

      I want to ask that how can i read, edit and write a xsl file. what classes i have to use. please guide me a little Thanx in advance Regards minamkhan Inam

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      You can read and write XML files (of which an XSLT is another XML grammar) using XmlTextReader and XmlTextWriter, but I doubt this is what you're looking for. If you're looking for graphical XML editors, you need to search CodeProject and the rest of the web. There's plenty of articles, how-tos, and even sample source and libraries out there. You just have to find them.

      Microsoft MVP, Visual C# My Articles

      I 1 Reply Last reply
      0
      • H Heath Stewart

        You can read and write XML files (of which an XSLT is another XML grammar) using XmlTextReader and XmlTextWriter, but I doubt this is what you're looking for. If you're looking for graphical XML editors, you need to search CodeProject and the rest of the web. There's plenty of articles, how-tos, and even sample source and libraries out there. You just have to find them.

        Microsoft MVP, Visual C# My Articles

        I Offline
        I Offline
        Inam
        wrote on last edited by
        #3

        Sir i try to explain the problem with a little example. I have a xml file an a xsl file, Now i have three fields in xml file let's say Name, Age, Address. Now i displays these fields to user as labels in windows Form. Now when user right click on any label i will display option to him e.g Font, Color different dialog etc. Now when user picks up the color i have to write that color against that field in xsl. will it be possible with XmlTextReader and XmlTextWriter Thanx in advance Regards minamkhan Inam

        H 1 Reply Last reply
        0
        • I Inam

          Sir i try to explain the problem with a little example. I have a xml file an a xsl file, Now i have three fields in xml file let's say Name, Age, Address. Now i displays these fields to user as labels in windows Form. Now when user right click on any label i will display option to him e.g Font, Color different dialog etc. Now when user picks up the color i have to write that color against that field in xsl. will it be possible with XmlTextReader and XmlTextWriter Thanx in advance Regards minamkhan Inam

          H Offline
          H Offline
          Heath Stewart
          wrote on last edited by
          #4

          You mean XML, not XSL. XSL is a transform you apply to an XML file that contains data, unless you mean you need to change that transform in order to add a color attributes of sorts; otherwise, forget XSL for the moment. You'd be better off using an XmlDocument so that you can easily traverse the DOM. See the documentation for the XmlDocument in the .NET Framework SDK for more information. If you keep track of which label belongs to which element or attributes (there are no fields in XML), you can use XPath to select node (via SelectNodes or SelectSingleNode for example) and then append an attributes. You really need to read the documentation for these classes, though, as well as some of the XML topics in the .NET Framework SDK, which you can view from http://msdn.microsoft.com/netframework[^].

          Microsoft MVP, Visual C# My Articles

          I 1 Reply Last reply
          0
          • H Heath Stewart

            You mean XML, not XSL. XSL is a transform you apply to an XML file that contains data, unless you mean you need to change that transform in order to add a color attributes of sorts; otherwise, forget XSL for the moment. You'd be better off using an XmlDocument so that you can easily traverse the DOM. See the documentation for the XmlDocument in the .NET Framework SDK for more information. If you keep track of which label belongs to which element or attributes (there are no fields in XML), you can use XPath to select node (via SelectNodes or SelectSingleNode for example) and then append an attributes. You really need to read the documentation for these classes, though, as well as some of the XML topics in the .NET Framework SDK, which you can view from http://msdn.microsoft.com/netframework[^].

            Microsoft MVP, Visual C# My Articles

            I Offline
            I Offline
            Inam
            wrote on last edited by
            #5

            Actually i want to change the transform and that is possible only with xsl. I think as u said that xslt is another grammer of xml. My problem will be solved by XmlTextReader and XmlTextWriter. Whats ur opinion Regards minamkhan Inam

            H 1 Reply Last reply
            0
            • I Inam

              Actually i want to change the transform and that is possible only with xsl. I think as u said that xslt is another grammer of xml. My problem will be solved by XmlTextReader and XmlTextWriter. Whats ur opinion Regards minamkhan Inam

              H Offline
              H Offline
              Heath Stewart
              wrote on last edited by
              #6

              XSL (deprecated) and XSLT are just XML documents implementing a certain schema. What I said before applies but how you do it completely depends on what content the transform produces. If you are transforming to HTML, then you need to either add a style attribute to whatever element will be output with the color: _color_; value. If you're transforming to something else, you'll need to change the color appropriately. And no, I don't agree that using an XmlTextWriter is the right way to do, especially when you clearly have no experience using them. Simply load the XSL document into an instance of an XmlDocument and make your changes to the DOM there. You can then save this XML document to a stream, be it a file stream, memory stream, or whatever. Apply this transform then to your XML document using an XslTransform. Again, be sure to read the relevent sections of the .NET Framework so you understand what you're doing and not just guessing and relying on IntelliSense. See Employing XML in the .NET Framework[^] for a lot of discussion on the topic, as well as examples and links to the class library documentation.

              Microsoft MVP, Visual C# My Articles

              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