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.
I. XSLT 2.0 solution:
when applied on the provided XML document:
produces the wanted, correct result:
If we replace in the transformation the current parameter:
with:
and apply the modified transformation on the same XML document again, we also get the wanted and correct result:
II. XSLT 1.0 solution:
when applied on the provided XML document:
produces the wanted, correct result:
If we replace in the transformation the current parameter:
with:
and apply the modified transformation on the same XML document again, we also get the wanted and correct result: