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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:46:59+00:00 2026-05-26T04:46:59+00:00

This is going to be a bit long and specific so please bear with

  • 0

This is going to be a bit long and specific so please bear with me. I understand how XSLT works but I don’t know all of the elements that do the operations. Any help you can provide would be appreciated.

Lets say I have a pilot manual for 737s written in XML. However, there are 3 types of 737s (400, 600, and 800) and although 90% of the manual is the same for all three types there are specific parts that are only for each type. Some pilots will only ever learn about 1 or 2 (or sometimes all 3) jets so I’d like to omit the sections that aren’t relevant for them. Here’s how I have the XML set up:

<manual>
    <section>A: This is relevant for every type</section>
    <section t600="no" t800="no">B: This is relevant only for the 737-400</section>
    <section t800="no">C: This is relevant for 737-400 and 737-600</section>
    <section t400="no">D: This is relevant for 737-600 and 737-800</section>
</manual>

I want to be able to specify, somehow, that I’m only interestd in, say, the 737-800 and get a manual like this:

<manual>
    <section>A: This is relevant for every type</section>
    <section>D: This is relevant for 737-600 and 737-800</section>
</manual>

Or for a different pilot that is interested in two jets, say the 737-400 and 737-600, the manual would look like this:

<manual>
    <section>A: This is relevant for every type</section>
    <section>B: This is relevant only for the 737-400</section>
    <section>C: This is relevant for 737-400 and 737-600</section>
    <section>D: This is relevant for 737-600 and 737-800</section>
</manual>

I have access to the source XML so if the way I’ve set it up doesn’t make sense I can change it. My thinking was since almost everything is the same for all types it makes more sense to opt-out, but I realize it might make it harder to match? I’m not sure.

Thanks again for taking a look! Let me know if I’ve left something out.

  • 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-26T04:47:00+00:00Added an answer on May 26, 2026 at 4:47 am

    I. XSLT 2.0 solution:

    <xsl:stylesheet version="2.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:xs="http://www.w3.org/2001/XMLSchema"
     exclude-result-prefixes="xs">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:param name="pInterests">
      <interest topic="t800"/>
     </xsl:param>
    
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match=
      "section[some $t in $pInterests/*/@topic
                satisfies
                  not($t = current()/@*[. eq 'no']/name())
              ]
      ">
       <section><xsl:apply-templates/></section>
     </xsl:template>
    
     <xsl:template match="section"/>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <manual>
        <section>A: This is relevant for every type</section>
        <section t600="no" t800="no">B: This is relevant only for the 737-400</section>
        <section t800="no">C: This is relevant for 737-400 and 737-600</section>
        <section t400="no">D: This is relevant for 737-600 and 737-800</section>
    </manual>
    

    produces the wanted, correct result:

    <manual>
       <section>A: This is relevant for every type</section>
       <section>D: This is relevant for 737-600 and 737-800</section>
    </manual>
    

    If we replace in the transformation the current parameter:

     <xsl:param name="pInterests">
      <interest topic="t800"/>
     </xsl:param>
    

    with:

     <xsl:param name="pInterests">
      <interest topic="t400"/>
      <interest topic="t600"/>
     </xsl:param>
    

    and apply the modified transformation on the same XML document again, we also get the wanted and correct result:

    <manual>
       <section>A: This is relevant for every type</section>
       <section>B: This is relevant only for the 737-400</section>
       <section>C: This is relevant for 737-400 and 737-600</section>
       <section>D: This is relevant for 737-600 and 737-800</section>
    </manual>
    

    II. XSLT 1.0 solution:

    <xsl:stylesheet version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:output omit-xml-declaration="yes" indent="yes"/>
     <xsl:strip-space elements="*"/>
    
     <xsl:param name="pInterests">
      <interest topic="t800"/>
     </xsl:param>
    
     <xsl:key name="kSectionTypeAttrByName" match="section/@*"
      use="concat(generate-id(..),'|', name())"/>
    
     <xsl:variable name="vInterests" select=
      "document('')/*/xsl:param[@name='pInterests']/*"/>
    
     <xsl:template match="node()|@*">
      <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
      </xsl:copy>
     </xsl:template>
    
     <xsl:template match="section">
      <xsl:variable name="vSec" select="."/>
    
      <xsl:variable name="vHasInterest">
       <xsl:for-each select="$vInterests/@topic">
        <xsl:variable name="vTopic" select="."/>
    
    
        <xsl:for-each select=
         "$vSec[not(key('kSectionTypeAttrByName',
                        concat(generate-id(),'|', $vTopic)
                       )
                    =
                     'no'
                    )
               ]">
          <xsl:text>1</xsl:text>
        </xsl:for-each>
    
       </xsl:for-each>
      </xsl:variable>
    
      <xsl:if test="string($vHasInterest)">
       <section><xsl:apply-templates/></section>
      </xsl:if>
     </xsl:template>
    </xsl:stylesheet>
    

    when applied on the provided XML document:

    <manual>
        <section>A: This is relevant for every type</section>
        <section t600="no" t800="no">B: This is relevant only for the 737-400</section>
        <section t800="no">C: This is relevant for 737-400 and 737-600</section>
        <section t400="no">D: This is relevant for 737-600 and 737-800</section>
    </manual>
    

    produces the wanted, correct result:

    <manual>
       <section>A: This is relevant for every type</section>
       <section>D: This is relevant for 737-600 and 737-800</section>
    </manual>
    

    If we replace in the transformation the current parameter:

     <xsl:param name="pInterests">
      <interest topic="t800"/>
     </xsl:param>
    

    with:

     <xsl:param name="pInterests">
      <interest topic="t400"/>
      <interest topic="t600"/>
     </xsl:param>
    

    and apply the modified transformation on the same XML document again, we also get the wanted and correct result:

    <manual>
       <section>A: This is relevant for every type</section>
       <section>B: This is relevant only for the 737-400</section>
       <section>C: This is relevant for 737-400 and 737-600</section>
       <section>D: This is relevant for 737-600 and 737-800</section>
    </manual>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is going to be the noobist of all noob questions, but what exactly
Okay this one may be a bit out from left field, but I'm going
I don't understand why this form wont send. The coding is very long and
This may be a really long stretch but would make life a fair bit
Trying to learn a bit about PDO and is going through this tutorial .
This is going to sound like a silly question, but I'm still learning C,
This is going to be hard to explain but I'll try my best. I
This is going to be a long post and just for fun, so if
I'm guessing this is going to involve regexp or something, but I'll give it
Ok saddle up cowboys, because this is going to be a long one. I

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.