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 document like this: <?xml version='1.0' encoding='UTF-8'?> <GateDocument> <!-- The document's
I have example.xml <?xml version=1.0 encoding=UTF-8 standalone=no?> <Document xmlns=urn:iso:std:iso:20022:tech:xsd:pain.001.001.02> <content> <books> <book> <qty>12</qty> <title>C++</title>
I have 50000 XML records like this in the database: <?xml version=1.0 encoding=UTF-8?> <root>
Currently, I have this version of the autocomplete control working when returning XML from
ok, so, i have an xml file that looks like this: <?xml version=1.0?> <Users>
I have an xml document: <?xml version=1.0 encoding=utf-8?> <Root> <Child name=MyType compareMode=EQ></Child> </Root> And
I have an Document object that is modeling a XML like this one: <RootNode
Currently, I have an XML document (called Food_Display_Table.xml) with data in a format like
I have a document that transforms xml to word. it starts like this: <?xml
I currently have a datasource from a client in the form of XML, this

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.