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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:51:55+00:00 2026-05-13T06:51:55+00:00

I currently have an XML document like this: <?xml version=1.0 encoding=ISO-8859-1?> <?xml-stylesheet type=text/xsl href=./transform.xsl?>

  • 0

I currently have an XML document like this:

<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href="./transform.xsl"?>
<Documentation><Tables>
<TABLE TABLE_NAME="FirstTable">
  <COLUMN COLUMN_NAME="FirstColumn" ORDINAL_POSITION="1" IS_NULLABLE="NO" DATA_TYPE="int" />
  <COLUMN COLUMN_NAME="SecondColumn" ORDINAL_POSITION="2" IS_NULLABLE="NO" DATA_TYPE="int" />
</TABLE>

...

</Tables><Comments>
<COMMENT ForTable="FirstTable" ForColumn="FirstColumn">Description of FirstColumn</COMMENT>
</Comments></Documentation>

My question is, how do I get the value of the COMMENT when looping over the tables and columns? I have:

<xsl:for-each select="//TABLE">
  ...
  <xsl:for-each select="COLUMN">
    ...
    <xsl:value-of select="//COMMENT[@ForTable = @TABLE_NAME and @ForColumn=@COLUMN_NAME]" />

But this doesn’t work. Any advice?

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

    Another variant to solve this would be:

    <xsl:for-each select="/Documentation/Tables/TABLE">
      <!-- select all comments for the current table name… -->
      <xsl:variable name="$comments" select="
        /Documentation/Comments/COMMENT[@ForTable = current()/@TABLE_NAME]
      "/>
    
      <xsl:for-each select="COLUMN">
        <!-- …of those, select the one with the current column name -->
        <xsl:value-of select="
          $comments[@ForColumn = current()/@COLUMN_NAME]
        " />
      </xsl:for-each>
    </xsl:for-each>
    

    The benefits are:

    • you only need one variable, instead of two
    • the inner for-each can run faster since it is looking at a smaller, pre-filtered data set

    Note that:

    • I use current() to refer to the XSLT context node within XPath predicates.
    • I avoid // in XPath expressions, since it has really bad performance characteristics and should not be used if possible. Your input document structure implies that // is not necessary.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an XML that goes like this: <?xml version=1.0 encoding=utf-8 ?> <colors> <color
Given the following XML file: <?xml version=1.0 encoding=UTF-8?> <process name=TestSVG2 xmlns=http://www.example.org targetNamespace=http://www.example.org xmlns:xsd=http://www.w3.org/2001/XMLSchema> <sequence>
I have a root element in my output xml document that has no attributes:
I'm looking to create XML Document objects in Java and serialize them to a
I'm needing to load an XML document into PHP that comes from an external
I have a framework that generates the XML, based on the HTTP request and
I have the following xml that's sent to me from a web service. I'm
How can I read an XML attribute using C#'s XmlDocument? I have an XML
I have a Java project connecting to an Ingres database and using the Spring

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.