How can I pass XML (including nodes) to a C# method in XSLT?

Discussion in 'XML' started by Hvid Hat, Mar 4, 2008.

  1. Hvid Hat

    Hvid Hat Guest

    How can I pass XML (including nodes) to a C# method in XSLT and process the
    XML?

    <msxsl:script language="C#" implements-prefix="user"><![CDATA[
    public string processXml(/* WHAT DATA TYPE? */)
    {
    // How do I process the XML? I'd like to use .getElementById or something
    similar if possible? I read something about using XPathNodeIterator.
    return "";
    }
    ]]></msxsl:script>

    ....
    ....
    ....

    <xsl:template match="Documents">
    <xsl:value-of select="user:processXml(.)" />
    </xsl:template
     
    Hvid Hat, Mar 4, 2008
    #1
    1. Advertising

  2. Hvid Hat wrote:
    > How can I pass XML (including nodes) to a C# method in XSLT and process
    > the XML?
    >
    > <msxsl:script language="C#" implements-prefix="user"><![CDATA[
    > public string processXml(/* WHAT DATA TYPE? */)
    > {
    > // How do I process the XML? I'd like to use .getElementById or
    > something similar if possible? I read something about using
    > XPathNodeIterator.
    > return "";


    The type should be XPathNodeIterator, that way you can pass in an
    XSLT/XPath node-set. In your function you can then iterate e.g.
    public string processXml (XPathNodeIterator it) {
    while (it.MoveNext()) {
    // ...
    }
    // need to return a string here to match the return type
    // but it is not clear what kind of string you want to construct
    }




    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
     
    Martin Honnen, Mar 4, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. gavnosis
    Replies:
    0
    Views:
    525
    gavnosis
    Aug 2, 2003
  2. Replies:
    4
    Views:
    684
  3. Elhanan

    including xml file in xslt?

    Elhanan, May 8, 2006, in forum: XML
    Replies:
    7
    Views:
    449
    Joe Kesselman
    May 10, 2006
  4. th3dude
    Replies:
    0
    Views:
    435
    th3dude
    Jan 3, 2007
  5. Eric
    Replies:
    1
    Views:
    2,056
    Pavel Lepin
    Feb 29, 2008
Loading...

Share This Page