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

  • Home
  • SEARCH
  • 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 8606215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:02:17+00:00 2026-06-12T03:02:17+00:00

for example i have following xml input: <Letter> <LetterProductInfo> <Paragraph> <DisplayOrder> 20 </DisplayOrder> <Text>

  • 0

for example i have following xml input:

<Letter>
  <LetterProductInfo>
    <Paragraph>
        <DisplayOrder>
            20
        </DisplayOrder>
        <Text>
            text abc
        </Text>
    </Paragraph>
  </LetterProductInfo>
</Letter>

<Letter>
    <LetterProductInfo>
    <Paragraph>
        <DisplayOrder>-10</DisplayOrder>
        <Text>
            text kkk
        </Text>
    </Paragraph>
  </LetterProductInfo>
</Letter>

<Letter>
   <LetterProductInfo>
    <Paragraph>
        <DisplayOrder>-20</DisplayOrder>
        <Text>
            text xyz
        </Text>
    </Paragraph>
  </LetterProductInfo>
</Letter>

i need help as to write xsl so that it will loop through all letter nodes and select the Text Based on the DisplayOrder’s value [ I can’t hardcode since i will not know what will the the displayorder id, all i know is that is an integer value]

something like:

<xsl:for-each select="Letter">
   <!--
   missing logic so that xsl:value-of select="?" will print
   1. test xyz - because its DisplayOrderId is -20
   2. text kkk - because its DisplayOrderId is -10
   3. text abc - because its DisplayOrderId is 20
    -->
</xsl:for-each>

Thanks.

  • 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-12T03:02:18+00:00Added an answer on June 12, 2026 at 3:02 am

    If I understand well your question, you want to output a certain string such as:

    1. test xyz

    for each Letter, but you want Letter elements sorted based on the numerical value of DisplayOrder.

    xsl:sort does that for you:

    <xsl:for-each select="Letter">
      <xsl:sort select="number(LetterProductInfo/Paragraph/DisplayOrder)"
        data-type="number"/>
      <!-- your code for processing a Letter goes here -->
    </xsl:for-each>
    

    Or you can as well do:

    <xsl:apply-templates select="Letter">
      <xsl:sort select="number(LetterProductInfo/Paragraph/DisplayOrder)"
        data-type="number"/>
      <!-- your code for processing a Letter goes into a separate xsl:template -->
    </xsl:apply-templates>
    

    I suggest you RTFM about xsl:sort at http://www.w3.org/TR/xslt20/#xsl-sort

    My code here assumes there’s only 1 node returned by LetterProductInfo/Paragraph/DisplayOrder.

    NB: for your next question, you might want to be more specific about what you expect as output. I assume you just want string and not HTML, for instance.

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

Sidebar

Related Questions

I have the following XML example that I need some help on. The sample
I have the following XML example <?xml version=1.0?> <test> <items> <item>item 1</item> <item>item 2</item>
So I have the following XML chain: $xml->assessment->outcomes_processing->outcomes->decvar->attributes()->cutvalue XML example In Some XML-files $xml->assessment->outcomes_processing->outcomes->...
I have the following in an XML file: <entry> ... <link href=http://www.example.com/somelink /> ...
for example I have the following: <div class=both> <textarea data-id=1 name=t1>Value 1</textarea> <input type=checkbox
I have a very specific deserialization need, see example below: say I have following
I have example the following xml: <LOCAL_AUTHORITY> <NAME>Derby</NAME> <REGION></REGION> <IRD>22%</IRD> <LOCAL_AUTHORITY> I have the
For example I have the following XML file: <?xml version=1.0 encoding=ISO-8859-1?> <bookstore> <book> <title
I have the following XML for example: <?xml version=1.0?> <extraslist> <extra id=0 enabled=1 quantityavailable=2
If I have the following struts.xml config: <action name=input> <result>/jsp/input.jsp</result> </action> <action name=result> <result>/jsp/result.jsp</result>

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.