Hi,
I am tring to match a data with one of the node. once a match is found i want to exit the loop. But in the xsl i have written even after finding the exact match the loop keeps on comparing with the remaining nodes that is taking substantial time(>1/2).
Request your input on how to solve this.


This is the partial data from the input XML that i am using.


PHP Code:
<?xml version="1.0" encoding="UTF-8"?>

<root>
<dictionary type="sup78">
<!-- Application -->
<analysisApp id="a_PedCard" label="Pediatric Cardiology">
<app>#tid5300</app>
</analysisApp>
<context>
<concept>
<csd>SNM3</csd>
<cv>G-A104</cv>
<cm>Lateral</cm>
</concept>
</context>
<context>
<concept>
<csd>SNM3</csd>
<cv>T-42500</cv>
<cm>Abdominal aorta</cm>
</concept>
<concept>
<csd>SRT</csd>
<cv>T-48503</cv>
<cm>Anomalous pulmonary vein</cm>
</concept>
</context>

   

<meas mode="2D" collection="Dimensions" label="RVAWd (2D)" id="m_ped_RVAWd_2D" result="r_Distance">
<app>#tid5300</app>
<group>Ventricle</group>
<site>Right Ventricle</site>
<concept>Thickness</concept>
<mode>#2d</mode>
<phase>#end_dias</phase>
<target>Right Ventricular Anterior Wall</target>
<comment>Right Ventricular Anterior Wall Diastolic Thinkness</comment>
</meas>
<meas mode="2D" collection="Dimensions" label="RVIDd (2D)" id="m_ped_RVIDd_2D" result="r_Distance">
<app>#tid5300</app>
<group>Ventricle</group>
<site>Right Ventricle</site>
<concept>Internal Dimension</concept>
<mode>#2d</mode>
<phase>#end_dias</phase>
<comment>Right Ventricular Internal Diastolic Dimension</comment>
</meas>



<IAConfig>
<Measurement MultiFetus="False" Id="m_ped_IVSd_2D" Category="cat_System" App="a_PedCard" Mode="mode_2D" UserLabel="" LocalLabel="IVSd (2D)" Tool="t_2D_Distance" ResultCount="5" Selector="sel_Avg" Bilateral="False" PrimaryResult="r_Distance">
<SubResult Name="r_Distance" Units="u_mm" UnitsString="cm" Precision="4" Conversion="0.1" DefaultChoice="True" UsedInCalc="True">
<DICOM>    
<app csd="DCM" cv="125195" cm="Pediatric Cardiac Ultrasound Report"/>
<group csd="SRT" cv="T-32410" cm="Interventricular septum"/>                
<site csd="SRT" cv="T-32410" cm="Interventricular septum"/>
<concept csd="LN" cv="59089-3" cm="ROI Thickness by US"/>
<mode csd="SRT" cv="G-03A2" cm="2D mode"/>
<phase csd="SRT" cv="F-32011" cm="End Diastole"/>
</DICOM>
</SubResult>
<Data Selector="sel_Avg">
<Result Index="0">
<SubResult Name="r_Distance" Value="13.7" Source="1318231201"/>
</Result>
<SelectedResult>
<SubResult Name="r_Distance" Value="13.7"/>
</SelectedResult>
</Data>
</Measurement>
<Measurement MultiFetus="False" Id="m_ped_LVIDd_2D" Category="cat_System" App="a_PedCard" Mode="mode_2D" UserLabel="" LocalLabel="LVIDd (2D)" Tool="t_2D_Distance" ResultCount="5" Selector="sel_Avg" Bilateral="False" PrimaryResult="r_Distance">
<SubResult Name="r_Distance" Units="u_mm" UnitsString="cm" Precision="4" Conversion="0.1" DefaultChoice="True" UsedInCalc="True">
<DICOM>
<app csd="DCM" cv="125195" cm="Pediatric Cardiac Ultrasound Report"/>
<group csd="99PMSBLUS" cv="C3618-14" cm="Ventricle"/>
<site csd="SRT" cv="T-32600" cm="Left Ventricle"/>
<concept csd="LN" cv="59090-1" cm="ROI Internal Dimension by US"/>
<mode csd="SRT" cv="G-03A2" cm="2D mode"/>
<phase csd="SRT" cv="F-32011" cm="End Diastole"/>
</DICOM>
</SubResult>
<Data Selector="sel_Avg">
<Result Index="0">
<SubResult Name="r_Distance" Value="21.9" Source="1318231204"/>
</Result>
<SelectedResult>
<SubResult Name="r_Distance" Value="21.9"/>
</SelectedResult>
</Data>
</Measurement>            
        
</IAConfig>
</root>




Here is the XSL to process the same

PHP Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:output method="xml" indent="yes" encoding="UTF-16"/>
<!-- Dictionary Lookup -->
<xsl:variable name="map" select="//dictionary/context/concept | //dictionary/concept"/>

<xsl:template match="/">
            <xsl:apply-templates select="//IAConfig/MasterList/Measurement"/>
</xsl:template>

<!-- Pick the measurements from the report -->
<xsl:template match="//IAConfig/MasterList/Measurement">
      <xsl:apply-templates select="//meas">
                <xsl:with-param name="measID" select="@Id"/>
                <xsl:with-param name="tool" select="@PrimaryResult"/>
        </xsl:apply-templates>        
</xsl:template>

<xsl:template match="//meas">
    <xsl:param name="measID"/>
    <xsl:param name="tool"/>
        <xsl:if test="@id=$measID and @result=$tool">
           <DICOM>
            <xsl:apply-templates select="*" mode="encode"/>
            </DICOM>
        </xsl:if>
</xsl:template>

<!-- skip comments -->
<xsl:template match="comment" mode="encode"/>

<!-- name[csd!cv!cm] -->
<xsl:template match="*" mode="encode">
    <!-- Lookup by @id or by cm -->
    <xsl:variable name="lookup" select="$map[@id = current() or cm = current()]"/>
    <!-- name[ -->
    <xsl:variable name="tagName" select="name()"/>
    
        <xsl:element name="{$tagName}"> 
                <xsl:attribute name="csd">
                    <xsl:value-of select="$lookup/csd"/>
                 </xsl:attribute>
               <xsl:attribute name="cv">
                    <xsl:value-of select="$lookup/cv"/>
                </xsl:attribute>
              <xsl:attribute name="cm">
                    <xsl:value-of select="$lookup/cm"/>
                </xsl:attribute>   
      </xsl:element>
    </xsl:template>
</xsl:stylesheet>






Regards
Bindhu M