Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 768551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:11:58+00:00 2026-05-14T18:11:58+00:00

I am triggering the transformation using a .NET code, unless I add EnableDocumentFunction property

  • 0

I am triggering the transformation using a .NET code,

unless I add “EnableDocumentFunction” property to the XSL-Setting, the program throws error saying .. “Usage of Document() function is prohibited“,

Actually the program is not editable and a kind of read-only .. is it possible to edit the XSL code itself so that I can use document() function??

The sample XSL and XMLs are Here:

Sample XML :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
    <xsl:output method="xml" indent="yes"/>

    <xsl:template match="@* | node()">
        <xsl:copy>
            <xsl:apply-templates select="@* | node()"/>
        </xsl:copy>
    </xsl:template>
  <xsl:variable name="State_Code_Trn">
    <State In="California" Out="CA"/>
    <State In="CA" Out="CA"/>
    <State In="Texas" Out="TX"/>
    <State In="TX" Out="TX"/>
  </xsl:variable>

  <xsl:template name="testing" match="test_node">
    <xsl:variable name="test_val">
      <xsl:value-of select="."/>
    </xsl:variable>
    <xsl:element name="{name()}">
      <xsl:choose>
      <xsl:when test="document('')/*/xsl:variable[@name='State_Code_Trn']
              /State[@In=$test_val]">
    <xsl:value-of select="document('')/*/xsl:variable[@name='State_Code_Trn']
              /State[@In=$test_val]/@Out"/>
      </xsl:when>
        <xsl:otherwise>
          <xsl:text>Other</xsl:text>
        </xsl:otherwise>
    </xsl:choose>
    </xsl:element>
  </xsl:template>

</xsl:stylesheet>

And the sample XML :

<?xml version="1.0" encoding="utf-8"?>
<root>
  <test_node>California</test_node>
  <test_node>CA</test_node>
  <test_node> CA</test_node>
  <test_node>Texas</test_node>
  <test_node>TX</test_node>
  <test_node>CAA</test_node>
  <test_node></test_node>
</root>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T18:11:59+00:00Added an answer on May 14, 2026 at 6:11 pm

    The document() function here is being used to access the XSLT document itself, and extract the contents of the xsl:variable. It is not actually necessary to use the document() function at all in this case.

    Because you are using Microsoft.Net here, you should be able to access msxml extension functions for XSLT. Indeed, the relevant namespace for msxml is already defined in the XSLT document

    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
    

    This means you will be able to make use of the node-set function to easily access the nodes within State_Code_Tran variable directly. To do this, try changing the existing xsl:choose function to as follows:

       <xsl:choose>
        <xsl:when test="msxsl:node-set($State_Code_Trn)/State[@In=$test_val]">
         <xsl:value-of select="msxsl:node-set($State_Code_Trn)/State[@In=$test_val]/@Out"/>
        </xsl:when>
        <xsl:otherwise>
         <xsl:text>Other</xsl:text>
        </xsl:otherwise>
       </xsl:choose>
    

    This should yield the following output

    <root>
    <test_node>CA</test_node>
    <test_node>CA</test_node>
    <test_node>Other</test_node>
    <test_node>TX</test_node>
    <test_node>TX</test_node>
    <test_node>Other</test_node>
    <test_node>Other</test_node>
    </root>
    

    (Note that you have a space before one of the ‘CA’s in your original XML, which is why it is coming out as ‘Other’. You may want to add some trimming function to cope with this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a C# code for triggering an XML to XML (XSLT) transformation.
is there a way to prevent triggering of property getter code while watching variables
I'm setting up a 2 builds in Teamcity, with scheduled triggering using cron expressions.
I have a jQuery AJAX post request that is unexpectedly triggering the error callback
I have a method in a class where I am triggering an error. /**
I have been facing an error when I trigger XSLT from a C# code,
I have the problem that my code isn't triggering the action in my backing
Apparently this line of code is triggering Object expected: var bPid = (b !=
I was using the $.click() method for triggering some events. But then I needed
I'm having a hard time manually triggering a property update with key-value-observing. Here's a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.