Subject: Re: [xsl] How to set an element as the context without using a for-each loop? From: "David Carlisle d.p.carlisle@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Wed, 1 May 2024 11:31:37 -0000 |
<xsl:sequence select="$record/(f:convert(Customer_or_Area_Code),f:convert(Cycle_Date),f:convert(Sequence_Number))"/> David On Wed, 1 May 2024 at 12:28, Roger L Costello costello@xxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > Hi Folks, > > I have a function that I pass "record" to: > > <xsl:function name="f:procedureLeg" as="element()+"> > <xsl:param name="record" as="element()"/> > ... > </xsl:function> > > "record" is an element that contains a bunch of child elements which the > function must process. > > So, "record" is the context for those child elements. > > One approach to process the child elements is to qualify them with > "$record/" like this: > > <xsl:function name="f:procedureLeg" as="element()+"> > <xsl:param name="record" as="element()"/> > > <xsl:sequence select="f:convert($record/Customer_or_Area_Code)"/> > <xsl:sequence select="f:convert($record/Cycle_Date)"/> > <xsl:sequence select="f:convert($record/Sequence_Number)"/> > ... > </xsl:function> > > That's horrible. Qualifying every child element is tedious and error prone > (I am likely to forget to qualify some child elements). > > Another approach, which avoids qualifying every child element, is to set > the context via a for-each loop: > > <xsl:function name="f:procedureLeg" as="element()+"> > <xsl:param name="record" as="element()"/> > > <xsl:for-each select="$record"> > <xsl:sequence select="f:convert(Customer_or_Area_Code)"/> > <xsl:sequence select="f:convert(Cycle_Date)"/> > <xsl:sequence select="f:convert(Sequence_Number)"/> > ... > </xsl:for-each> > </xsl:function> > > That's lousy as well. "record" is just a single element; I shouldn't be > looping over a single element (in my opinion). > > Is there a better way? One that doesn't involve qualifying every child > element and doesn't involve looping over a single element? > > /Roger
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] How to set an element as the , Roger L Costello cos | Thread | Re: [xsl] How to set an element as , Pieter Masereeuw pie |
[xsl] How to set an element as the , Roger L Costello cos | Date | Re: [xsl] How to set an element as , Pieter Masereeuw pie |
Month |