Re: [xsl] Help with using position()

Subject: Re: [xsl] Help with using position()
From: Vincenzo Menanno <enzo13@xxxxxxx>
Date: Sun, 01 Jan 2012 04:45:50 -0800
Martin,

I think I spoke too soon. Adding <xsl:number level="any" count="Calculation"/> is a performance killer.

Usually these files are very large and they could have Calculation nodes in other parts of the document what I was hoping for is to have a way to only count the unique instances of Calculation within a certain catalog.

I tried this:

<xsl:number level="any" from="BaseTableCatalog" count="Calculation"/>

But the first item comes in with a value of 1 and all others come in with a value of 0

I am using different XSLs to parse different sections. So I was hoping that I would be able to use the same logic for both Calculation and Chunks to keep them in sync. Its ok that the numbering sequence starts over in each catalog.

And hoping that the performance won't be affected to much.

Here is a sample of what I have to deal with
---------------------------------------
<?xml version="1.0" encoding="UTF-16"?>
<FMPReport link="Summary.xml" creationTime="6:44:43 PM" creationDate="12/30/2011" type="Report" version="11.0v1">
   <File name="Test.fmp7" path="/Users/enzo13/Desktop/process/CMS/">
      <BaseTableCatalog>
         <BaseTable id="129" records="2" name="Test">
            <FieldCatalog>
               <Field id="1" dataType="Number" fieldType="Calculated" name="red">
                  <Calculation table="Test"><![CDATA[Left ( name; 3 ) & "sdkfhskdfhsdf" & sdafsadf & Asin ( ZARK::boart ) & sdafsadf Copy2]]></Calculation>
                  <DisplayCalculation>
                     <Chunk type="FunctionRef">Left</Chunk>
                     <Chunk type="NoRef"> ( </Chunk>
                     <Chunk type="FieldRef">
                        <Field table="Test" id="1" name="name"/>
                     </Chunk>
                     <Chunk type="NoRef">; 3 ) &amp; &quot;sdkfhskdfhsdf&quot; &amp; </Chunk>
                     <Chunk type="CustomFunctionRef">sdafsadf</Chunk>
                     <Chunk type="NoRef"> &amp; </Chunk>
                     <Chunk type="FunctionRef">Asin</Chunk>
                     <Chunk type="NoRef"> ( </Chunk>
                     <Chunk type="FieldRef">
                        <Field table="ZARK" id="1" name="boart"/>
                     </Chunk>
                     <Chunk type="NoRef"> ) &amp; </Chunk>
                     <Chunk type="CustomFunctionRef">sdafsadf Copy2</Chunk>
                  </DisplayCalculation>
                  <Comment/>
                  <AutoEnter alwaysEvaluate="False"/>
                  <Storage storeCalculationResults="False" indexLanguage="English" global="False" maxRepetition="1"/>
               </Field>
               <Field id="3" dataType="Text" fieldType="Normal" name="blue">
                  <Comment/>
                  <AutoEnter allowEditing="True" overwriteExistingValue="False" alwaysEvaluate="False" constant="False" furigana="False" lookup="False" calculation="True">
                     <ConstantData/>
                     <Calculation table="Test"><![CDATA[Asin ( sfksjfhd )]]></Calculation>
                     <DisplayCalculation>
                        <Chunk type="FunctionRef">Asin</Chunk>
                        <Chunk type="NoRef"> ( </Chunk>
                        <Chunk type="FieldRef">
                           <Field table="Test" id="2" name="sfksjfhd"/>
                        </Chunk>
                        <Chunk type="NoRef"> )</Chunk>
                     </DisplayCalculation>
                  </AutoEnter>
                  <Validation message="False" maxLength="False" valuelist="False" calculation="False" alwaysValidateCalculation="False" type="OnlyDuringDataEntry">
                     <NotEmpty value="False"/>
                     <Unique value="False"/>
                     <Existing value="False"/>
                     <StrictValidation value="False"/>
                  </Validation>
                  <Storage autoIndex="True" index="None" indexLanguage="English" global="False" maxRepetition="1"/>
               </Field>
            </FieldCatalog>
         </BaseTable>
      </BaseTableCatalog>
      <PrivilegesCatalog>
         <PrivilegeSet comment="" id="4" allowModifyPassword="False" managedExtended="False" menu="Minimal" idleDisconnect="True" overrideValidationWarning="False" exporting="False" printing="False" name="sfkjshfsdf">
            <Records value="Custom">
               <TableList>
                  <BaseTable id="129" name="Test">
                     <Create value="False"/>
                     <View value="Limited">
                        <Calculation><![CDATA[Left ( name; 3 ) & "sdkfhskdfhsdf" & sdafsadf & Asin ( ZARK::boart ) & sdafsadf Copy2]]></Calculation>
                        <DisplayCalculation>
                           <Chunk type="FunctionRef">Left</Chunk>
                           <Chunk type="NoRef"> ( </Chunk>
                           <Chunk type="FieldRef">
                              <Field table="Test" id="1" name="name"/>
                           </Chunk>
                           <Chunk type="NoRef">; 3 ) &amp; &quot;sdkfhskdfhsdf&quot; &amp; </Chunk>
                           <Chunk type="CustomFunctionRef">sdafsadf</Chunk>
                           <Chunk type="NoRef"> &amp; </Chunk>
                           <Chunk type="FunctionRef">Asin</Chunk>
                           <Chunk type="NoRef"> ( </Chunk>
                           <Chunk type="FieldRef">
                              <Field table="ZARK" id="1" name="boart"/>
                           </Chunk>
                           <Chunk type="NoRef"> ) &amp; </Chunk>
                           <Chunk type="CustomFunctionRef">sdafsadf Copy2</Chunk>
                        </DisplayCalculation>
                     </View>
                     <Edit value="Limited">
                        <Calculation><![CDATA[Left ( name; 3 ) & "sdkfhskdfhsdf" & sdafsadf & Asin ( ZARK::boart ) & sdafsadf Copy2]]></Calculation>
                        <DisplayCalculation>
                           <Chunk type="FunctionRef">Left</Chunk>
                           <Chunk type="NoRef"> ( </Chunk>
                           <Chunk type="FieldRef">
                              <Field table="Test" id="1" name="name"/>
                           </Chunk>
                           <Chunk type="NoRef">; 3 ) &amp; &quot;sdkfhskdfhsdf&quot; &amp; </Chunk>
                           <Chunk type="CustomFunctionRef">sdafsadf</Chunk>
                           <Chunk type="NoRef"> &amp; </Chunk>
                           <Chunk type="FunctionRef">Asin</Chunk>
                           <Chunk type="NoRef"> ( </Chunk>
                           <Chunk type="FieldRef">
                              <Field table="ZARK" id="1" name="boart"/>
                           </Chunk>
                           <Chunk type="NoRef"> ) &amp; </Chunk>
                           <Chunk type="CustomFunctionRef">sdafsadf Copy2</Chunk>
                        </DisplayCalculation>
                     </Edit>
                  </BaseTable>
               </TableList>
            </Records>
         </PrivilegeSet>
      </PrivilegesCatalog>
      <ScriptCatalog>
         <Script includeInMenu="True" runFullAccess="False" id="14" name="sdfdsf Copy8">
            <StepList>
               <Step enable="True" id="122" name="New Window">
                  <Name>
                     <Calculation><![CDATA[Left ( Test::name; 3 ) & "sdkfhskdfhsdf" & sdafsadf & Asin ( ZARK::boart ) & sdafsadf Copy2]]></Calculation>
                     <DisplayCalculation>
                        <Chunk type="FunctionRef">Left</Chunk>
                        <Chunk type="NoRef"> ( </Chunk>
                        <Chunk type="FieldRef">
                           <Field table="Test" id="1" name="name"/>
                        </Chunk>
                        <Chunk type="NoRef">; 3 ) &amp; &quot;sdkfhskdfhsdf&quot; &amp; </Chunk>
                        <Chunk type="CustomFunctionRef">sdafsadf</Chunk>
                        <Chunk type="NoRef"> &amp; </Chunk>
                        <Chunk type="FunctionRef">Asin</Chunk>
                        <Chunk type="NoRef"> ( </Chunk>
                        <Chunk type="FieldRef">
                           <Field table="ZARK" id="1" name="boart"/>
                        </Chunk>
                        <Chunk type="NoRef"> ) &amp; </Chunk>
                        <Chunk type="CustomFunctionRef">sdafsadf Copy2</Chunk>
                     </DisplayCalculation>
                  </Name>
               </Step>
            </StepList>
         </Script>
      </ScriptCatalog>
   </File>
</FMPReport>

On Jan 1, 2012, at 2:52 AM, Martin Honnen wrote:

> Vincenzo Menanno wrote:
>> A few more questions using the example below.
>> 
>> I have 1 xsl that gets me all the Calculations and using postion() function I am able to get the position number of the calculation.
>> 
>> <xsl:value-of select="position()"/>
>> 
>> All I want is a unique number or sequence number of each calculation. So is position() the most effective way to do this?
> 
> position() works as long as your for-each or apply-templates processes only the nodes you are interested in to number.
> In the more general case (for instance when you process all child elements but are only interested in numbering "foo" elements) you would use xsl:number (http://www.w3.org/TR/xslt#number) as in
>  <xsl:number count="foo"/>

Current Thread