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. How to Check whether we can use XSL 2.0?

How to Check whether we can use XSL 2.0?

Scheduled Pinned Locked Moved XML / XSL
xmlhelptutorialquestion
4 Posts 3 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.
  • R Offline
    R Offline
    Rocky
    wrote on last edited by
    #1

    Hi everyone, well I'm kind of a new bee here and I wanted to ask a bit naive questions so here it goes. How do we know whether we can use XSL 2.0? Actually I was trying to use the new 'replace' function in XSLT. I changed the header to but its giving me error that replace is not a valid XSLT or XPath Function. So what should I do now? Any ideas?? Thanks in advance Rocky You can't climb up a ladder with your hands in your pockets.

    G 1 Reply Last reply
    0
    • R Rocky

      Hi everyone, well I'm kind of a new bee here and I wanted to ask a bit naive questions so here it goes. How do we know whether we can use XSL 2.0? Actually I was trying to use the new 'replace' function in XSLT. I changed the header to but its giving me error that replace is not a valid XSLT or XPath Function. So what should I do now? Any ideas?? Thanks in advance Rocky You can't climb up a ladder with your hands in your pockets.

      G Offline
      G Offline
      George L Jackson
      wrote on last edited by
      #2

      XSLT 2.0 and XPath 2.0 is not available in the current version of .NET. However, you can find .NET libraries here: http://saxon.sourceforge.net/[^] and http://www.altova.com/altovaxml.html[^]

      "We make a living by what we get, we make a life by what we give." --Winston Churchill

      C 1 Reply Last reply
      0
      • G George L Jackson

        XSLT 2.0 and XPath 2.0 is not available in the current version of .NET. However, you can find .NET libraries here: http://saxon.sourceforge.net/[^] and http://www.altova.com/altovaxml.html[^]

        "We make a living by what we get, we make a life by what we give." --Winston Churchill

        C Offline
        C Offline
        ChrisKo 0
        wrote on last edited by
        #3

        Or you could use a XSLT Extension Object and write your own replace method. These URLs should help you find the correct path. http://msdn2.microsoft.com/en-us/library/wxaw5z5e(VS.80).aspx[^] and http://msdn2.microsoft.com/en-us/library/tf741884(VS.80).aspx[^]

        G 1 Reply Last reply
        0
        • C ChrisKo 0

          Or you could use a XSLT Extension Object and write your own replace method. These URLs should help you find the correct path. http://msdn2.microsoft.com/en-us/library/wxaw5z5e(VS.80).aspx[^] and http://msdn2.microsoft.com/en-us/library/tf741884(VS.80).aspx[^]

          G Offline
          G Offline
          George L Jackson
          wrote on last edited by
          #4

          Here is some sample code for XSLT Extension Object that I had playing around with recently: using namespace System; using namespace System::IO; using namespace System::Text; using namespace System::Xml; using namespace System::Xml::XPath; using namespace System::Xml::Xsl; public ref class ParseCdata { public: ParseCdata(String^ xmlText) : doc(gcnew XmlDocument) { doc->LoadXml(xmlText); } String^ GetCData(XPathNodeIterator^ nodes) { StringBuilder^ result = gcnew StringBuilder; while (nodes->MoveNext()) { XPathNavigator^ nodesNav = nodes->Current; String^ xpath = String::Format("/test/data[@id='{0}']", nodes->Current->GetAttribute("id", String::Empty)); XmlNodeList^ dataNodes = doc->SelectNodes(xpath); for each (XmlNode^ node in dataNodes) { for each (XmlNode^ child in node->ChildNodes) { if (child->NodeType == XmlNodeType::CDATA) result->AppendFormat("-!!!{0}!!!-", child->Value); } } } return result->ToString(); } private: XmlDocument^ doc; }; int main(array ^args) { String^ xmlText = "" "" " " ""; String^ xsltText = "" "" "" "\n" "\t\n" "\n" "" "" "" "" ""; StringReader^ strReader1; XmlReader^ xmlReader1; StringReader^ strReader2; XmlReader^ xmlReader2; try { strReader1 = gcnew StringReader(xsltText); xmlReader1 = XmlReader::Create(strReader1); XslCompiledTransform^ xslt = gcnew XslCompiledTransform; xslt->Load(xmlReader1); strReader2 = gcnew StringReader(xmlText); xmlReader2 = XmlReader::Create(strReader2); XPathDocument^ xml = gcnew XPathDocument(xmlReader2); XsltArgumentList^ xsltArgs = gcnew XsltArgumentList; ParseCdata^ cdata = gcnew ParseCdata(xmlText); xsltArgs->AddExtensionObject("urn:cdata-conv", cdata); xslt->Transform(xml, xsltArgs, Console::Out); } catch (Exception^ excp) { Console::WriteLine(excp->ToString()); } finally { if (xmlReader2 != nullptr) xmlReader2->Close(); if (strReade

          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