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

Ask A Question

Stats

  • Questions 494k
  • Answers 494k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer No, doesn´t happen always. Executing both branches happens only if… May 16, 2026 at 10:57 am
  • Editorial Team
    Editorial Team added an answer Do you mean ar[filenumber,k,m] = data? I don't think you… May 16, 2026 at 10:57 am
  • Editorial Team
    Editorial Team added an answer You can not be 100% sure, just like you can't… May 16, 2026 at 10:57 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have written a C# code for triggering an XML to XML (XSLT) transformation.
I have been facing an error when I trigger XSLT from a C# code,
I am triggering an ant script (via cruise control), and would like to be
Seems like the subtraction is triggering some kind of issue and the resulting value
I'm having a problem triggering events on items that have been added to the
I created a GridView in code with a DataTable as its data source which
I have modified the title of the question after finding the answer :) :P
I want to find out the difference between two Dates (in terms of minutes)
I have QGraphicsTextItem objects on a QGraphicsScene . The user can scale the QGraphicsTextItem
Premise I'd like to use HTML Purifier to transform <body> tags to <div> tags,

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.