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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:30:14+00:00 2026-06-07T20:30:14+00:00

A variable $rows has a list of node ids that key into some source

  • 0

A variable $rows has a list of node ids that key into some source XML.

<row>
   <node id="d0113" />
   <node id="d0237" />
   <node id="d0321" />
</row>
<row>
   <node id="c0278" />
   <node id="d0137" />
   <node id="e0021" />
</row>

What is a good way to test, before processing each <row>, whether any of nodes keyed to actually exist in a node-set $set?

All I’ve come up with is

<xsl:for-each select="row">
  <xsl:variable name="test">  
    <xsl:for-each select="node">
      <xsl:value-of select="boolean($set//*[generate-id()=current()/@id]) * 1"/>
    </xsl:for-each>                  
  </xsl:variable>
  <xsl:if test="$test&gt;0">
    <!-- go ahead and process the row -->
  </xsl:if>
</xsl:for-each>
  • 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-07T20:30:16+00:00Added an answer on June 7, 2026 at 8:30 pm
      <xsl:value-of select="boolean($set//*[generate-id()=current()/@id]) * 1"/>
    

    This will in most cases return false() so this whole method of “indexing” is incorrect.

    This is because the values of generate-id() for any node in an XML document aren’t guaranteed to be the same from transformation to transformation.

    Even if in the provided XML document any node/@id attribute was generated to have the value of generate-id() on some particular node of the second document, nothing guarantees that in a consequent new transformation generate-id() on that same node will produce the same valu as the one that was used to generate the respective node/@id.

    Recommendation:

    For such indexing use a more stable function of a node — one example of such function is the XPath expression that selects exactly that node.

    If the document hasn’ been modified, that XPath expression is going always to select that node.

    Update:

    In a comment the OP maintains that the node/@id attributes are both generated and used in the same transformation.

    In this case, this single XPath expression produces a boolen that indicates whether or not $set contains at least one node whose generate-id() is one of the node/@id attributes of another document:

    boolean($set[generate-id() = someExpression/row/node/@id])
    

    In a test attribute of a conditional instruction, just the argument to boolean() above can be used.

    Explanation:

    The expression:

    $set[generate-id() = someExpression/row/node/@id])]
    

    Selects all nodes in $set whose value of generate-id() is equal to at least one someExpression/row/node/@id attribute’s value (someExpression here stands for the missing location steps about which we know nothing, since no XML document has been provided).

    By definition, boolean($someNodeSet) is always true() if the node-set $someNodeSet contains at least one node, and is false if $someNodeSet is the empty node-set.

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

Sidebar

Related Questions

I have a form that has 8 columns and a variable number of rows
I want to have a table that has 4 rows and a variable number
How do i assign variable cats so that it pulls the rows in database
As we can select multiple rows into single variable declared as some_table.rowtype in SQL.
I have a table (table variable in-fact) that holds several thousand (50k approx) rows
I need to insert or delete some rows depending on what a variable states.
How would you assign a variable the total number of rows a table has
I have a script that appends some rows to a table. One of the
I have a table containing a large number of rows. Each row has 2
How to insert multiple rows using variable in Oracle database through PHP? My query-:

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.