-
January 15th, 2023, 03:50 PM
#1
XSLT question
Hi,
I'm quite new to xslt and I'm trying to understand the inner for-loop in the code below. I think
it loops over all <ClassifiedProductDefinition> elements with a <SpeciesGroupKey> that matches the
the one in <SpeciesGroupDefinition> and where none of the preceding <ClassifiedProductDefinition>
elements have the same <SpeciesGroupKey> and <ProductGroupName> as the current <ClassifiedProductDefinition>
element. Is this correct or am I missing something here?
Code:
<xsl:variable name="productGroups">
<xsl:for-each select="hpr:SpeciesGroupDefinition">
<xsl:variable name="species" select="hpr:SpeciesGroupKey"/>
<xsl:for-each select="../hpr:ProductDefinition/hpr:ClassifiedProductDefinition[hpr:SpeciesGroupKey = $species and not(./hpr:ProductGroupName = preceding::[hpr:SpeciesGroupKey = $species]/hpr:ProductGroupName)]">
<Product>
<xsl:copy-of select="hpr:SpeciesGroupKey"/>
<xsl:copy-of select="hpr:ProductGroupName"/>
</Product>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
-
January 15th, 2023, 11:34 PM
#2
Re: XSLT question
My first suggestion would be for you to generate a minimal XML document containing a couple of elements
- one which passes the tests (as you understand it)
- one which fails the tests
Or take an existing document and make a copy of it, containing just a few representative elements.
Does applying your xslt to that document produce the result you want?
-
January 16th, 2023, 07:51 AM
#3
Re: XSLT question
Thanks for the suggestion, Salem. What I'm not sure of is if the condition [hpr:SpeciesGroupKey = $species]
is negated or if it selects all elements with same <SpeciesGroupKey> and different <ProductGroupName>.
I didn't write the xslt code. I'm just trying to understand what it does.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|