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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:12:30+00:00 2026-06-09T05:12:30+00:00

The problem I’m trying to solve is to get all elements that contain only

  • 0

The problem I’m trying to solve is to get all elements that contain only a unique text element but at the same time also being able to exclude node trees based on a element name passed as a parameter to the XSLT sheet.

The part to select all the nodes containing only a unique text element that’s not empty was relatively easy:

$StartNode//element()/text()[normalize-space(.)]/parent::*

where $StartNode is a Xpath Expression to a specific Element in the XML document.

Now the part I had quite some some problems with, excluding an specific node tree from the results:

so I was hoping for something like:

$StartNode//element()/text()[normalize-space(.)]/parent::*[not(ancestor::**$element_to_be_excluded**)]

where $element_to_be_excluded is the element name to exclude.

But it’s not possible to use a variable on that part of the expression…

So I came up with this solution

<xsl:variable name="ancestors_of_current_node" as="xs:string*">
   <xsl:sequence select="$current_parent_node/ancestor::*/name()"/>
</xsl:variable>
<xsl:variable name="is_value_in_sequence" as="xs:boolean" select="functx:is-value-in-sequence($exclude_node_local_name, $ancestors_of_current_node)"/>
<xsl:if test="not($is_value_in_sequence)">
    <xsl:call-template name="dataElementMap">
       <xsl:with-param name="node_item" select="$current_parent_node"/>
    </xsl:call-template>
</xsl:if>

where functx:is-value-in-sequence is:

<xsl:function name="functx:is-value-in-sequence" as="xs:boolean" xmlns:functx="http://www.functx.com">
  <xsl:param name="value" as="xs:anyAtomicType?"/>
  <xsl:param name="seq" as="xs:anyAtomicType*"/>
  <xsl:sequence select="$value = $seq"/>
</xsl:function>

Now the question is, it’s there a more elegant way to solve this problem?

Thanks in advance for any hint.

Regards
Vlax

  • 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-06-09T05:12:31+00:00Added an answer on June 9, 2026 at 5:12 am

    Instead of doing (which doesn’t work due to the variable, as you mention)

    $StartNode//element()/text()[normalize-space(.)]
       /parent::*[not(ancestor::$element_to_be_excluded)]
    

    Could you try this instead, to check the ancestor’s name?

    $StartNode//element()/text()[normalize-space(.)]
       /parent::*[not(ancestor::*[local-name() = $element_to_be_excluded])]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: Trying to create a Mix that is applied to the AVPlayerItem, but it
Problem: I have a table that prints out vertical but I would like it
Problem: I need to get a random element for a container and also delete
Problem I am trying to access developers.facebook.com with a user account , but I
Problem: Been struggling to get my code to load external shaders and it is
Problem: I am trying to build a recursive tree using a function and data
Problem occured when i tried to display xml data that has been taken by
Problem: I can set the exposureMode property of AVCaptureDevice, but it does not stay
Problem: I'm working on a website where there is a dial that displays 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.