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 6214657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T06:54:59+00:00 2026-05-24T06:54:59+00:00

I want to ask. there is posible to add condition which will be checking

  • 0

I want to ask. there is posible to add condition which will be checking xml data with lookup table, and if we didnt’t have value in lookup table add const 8 to output?
xslt Code:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="Department" match="Department" use="../Collection"/>
    <xsl:template match="/">
    <document>
        <xsl:apply-templates/>
    </document>
</xsl:template>
 <xsl:template match="line">
     <xsl:variable name="inputDep" select="field[@id='3']"/>
<Department>
    <xsl:for-each select="document('lookup.xml')">
        <xsl:for-each select="key('Deparment',$inputDep)">
            <xsl:value-of select="."/>
        </xsl:for-each>
    </xsl:for-each>
</Department>

 </xsl:template>

</xsl:stylesheet>

lookup table:

<document>
    <line-item>
        <Collection>1</Collection>
        <Department>3</Department>
    </line-item>
    <line-item>
        <Collection>2</Collection>
        <Department>1</Department>
    </line-item>
    <line-item>
        <Collection>3</Collection>
        <Department>2</Department>
    </line-item>
</document>

xml file:

<document>
    <line id="0">
        <field id="3"><![CDATA[1]]></field>
    </line>
    <line id="1">
        <field id="3"/>
    </line>
    <line id="2">
        <field id="3"/><![CDATA[4]]></field>
    </line>
</document>

result:

<Department>3<Department>
<Department>8<Department>
<Department>8<Department>
  • 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-24T06:55:00+00:00Added an answer on May 24, 2026 at 6:55 am

    You could assign the looked-up value to a variable and choose what to output based on whether anything was found.

    Edit 2: A full demonstration stylesheet:

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
      <xsl:key name="Department" match="Department" use="../Collection"/>
    
      <xsl:template match="/">
        <document>
          <xsl:apply-templates/>
        </document>
      </xsl:template>
    
      <xsl:template match="line">
        <xsl:variable name="inputDep" select="field[@id='3']"/>
        <Department>
          <xsl:for-each select="document('lookup.xml')">
            <xsl:variable name="value" select="key('Department',$inputDep)"/>
            <xsl:choose>
              <xsl:when test="$value">
                <xsl:value-of select="$value"/> <!-- see note -->
              </xsl:when>
              <xsl:otherwise>8</xsl:otherwise>
            </xsl:choose>
          </xsl:for-each>
        </Department>
      </xsl:template>
    
    </xsl:stylesheet>
    

    Note: Replaced the xsl:for-each loop in the original stylesheet with a simple xsl:value-of, assuming that the looping the values was not intentional. If it actually was, you can replace this with a for-each loop.

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

Sidebar

Related Questions

I want to ask you if there is a possibility to program a Java
want to ask user to input something but not want to wait forever. There
i want ask some question about asp.net mvc Is static constructor will init every
I want to ask in which phase of Control Execution Lifecycle is the Server-Side-Code
I want to ask how to add a computed column in BIRT that compute
I have made an out-of-browser silverlight application which I want to automatically update every
As a beginner programmer, I want to ask is there any way to using
I want to ask you , how to pass variable, there's the example: I
I want to ask about scheduling, is there any MySQL command for scheduling. For
hihi i have a question that i want to ask about c# and window

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.