Is it possible to use a lookup table if the key changes? In the example below, a variable is used as the key, but it's not working because XSLT variables are not really variable.
It is absolutely not clear what you want to do
But I assume you are looking for dealing with a combined key?
Wel, combined keys can easily be achieved by concatening the keys
or by having an "and" inside the predicate.
Can you explain what exactly you want to do?
0
mariitaAuthor Commented:
Sorry, the snippet did not have enough context.
I want to loop through the list of NAICS codes in the XML file, and use a composite key (consisting of Organization, Facility, NAICS) to look up the corresponding Classification and Percentage in the lookup table. Because this facility has more than one NAICS code, the $ThisFacilityNAICS variable cannot be set to a specific value.
no need to compound in the lookup, it is better to keep them seperated
0
There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.
that is a bit tricky (call it the higher science of XSLT :-)
[@Org = /Report/OrganisationNameEn]
because of the document('') the context in teh predicate is the XSLT file, no longer the source XML file. If you need to do that, you need to bind the source to a variable first
<xsl:variable name="source" select="."/>
at the top level of your stylesheet
then you can do this
[@Org = $source/Report/OrganisationNameEn]
0
mariitaAuthor Commented:
How about the third predicate? How would I specify the context?
Hi, I am just giving suggestions, so I have not looked into your stylesheet in detail (will only have time tomorrow, will visit family soon)
As soon as you start looking inside the lookup table, the context will be set to that lookup table, so outside the source XML
In order to get the old context back, you need storage in a variable
You can store the current context at every level
just store away (at the right context) the NAICSCodeEn value as $this-NAICSCodeEn
and use it in the lookup [@NAICS = $this-NAICSCodeEn]
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
But I assume you are looking for dealing with a combined key?
Wel, combined keys can easily be achieved by concatening the keys
or by having an "and" inside the predicate.
Can you explain what exactly you want to do?