3249. EPMO Open Source Coordination Office Redaction File Detail Report

Produced by Araxis Merge on 6/9/2017 3:49:59 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

3249.1 Files compared

# Location File Last Modified
1 Fri Jun 9 19:49:59 2017 UTC
2 eHealth_Exch (eHealth Exchange Enhancements) Build 3 docs & code_May_2017.zip\VAP_CIF_CODE0502.zip\VAP_CIF_CODE0502\VAP_CIF_CODE0502\nvap-common\src\main\resources\gov\va\nvap\common\hl7 XMLToER7.xsl Fri Apr 21 20:03:26 2017 UTC

3249.2 Comparison summary

Description Between
Files 1 and 2
Text Blocks Lines
Unchanged 0 0
Changed 0 0
Inserted 1 2331
Removed 0 0

3249.3 Comparison options

Whitespace
Character case Differences in character case are significant
Line endings Differences in line endings (CR and LF characters) are ignored
CR/LF characters Not shown in the comparison detail

3249.4 Active regular expressions

No regular expressions were active.

3249.5 Comparison detail

        1   <?xml 
        2     version="1 .0"
        3   ?>
        4  
        5   <!-- A tra nsformatio n for mapp ing an XML  encoded H L7 message  into an e r7 
        6           en coded mess age. The t ransformat ion also h andles the  Batch (BH S and BTS)  
        7           an d File (FH S and FTS)  segments,  BUT IT DO ES NOT HAN DLE A BATC HED SET OF  
        8           ME SSAGES, i. e., it doe s not hand le a prope rly constr ucted XML  batch file  
        9           wi th HL7 mes sages wrap ped in CDA TA. -->
        10  
        11   <xsl:style sheet 
        12     version="1 .0"
        13           
        14     xmlns:xsl= "http://ww w.w3.org/1 999/XSL/Tr ansform"
        15   >
        16    
        17             
        18     <xsl:outpu
        19      method="te xt" 
        20      encoding=" UTF-8" 
        21     />
        22    
        23             
        24     <xsl:varia ble 
        25      name="nl"
        26     >
        27                       
        28      <xsl:text>
        29       &#13;
        30      </xsl:text >
        31              
        32     </xsl:vari able>
        33    
        34             
        35     <!-- MSH s pecial cha rs -->
        36             
        37     <xsl:varia ble 
        38      name="fiel dSeparator Message"
        39     >
        40                       
        41      <xsl:value -of 
        42       select="no rmalize-sp ace(//MSH/ MSH.1)" 
        43      />
        44              
        45     </xsl:vari able>
        46             
        47     <xsl:varia ble 
        48      name="msh2 "
        49     >
        50                       
        51      <xsl:value -of 
        52       select="no rmalize-sp ace(//MSH/ MSH.2)" 
        53      />
        54              
        55     </xsl:vari able>
        56             
        57     <xsl:varia ble 
        58      name="comp SeparatorM essage"
        59     >
        60                       
        61      <xsl:value -of 
        62       select="su bstring($m sh2, 1, 1)
        63      />
        64              
        65     </xsl:vari able>
        66             
        67     <xsl:varia ble 
        68      name="repC harMessage "
        69     >
        70                       
        71      <xsl:value -of 
        72       select="su bstring($m sh2, 2, 1)
        73      />
        74              
        75     </xsl:vari able>
        76             
        77     <xsl:varia ble 
        78      name="esca peCharMess age"
        79     >
        80                       
        81      <xsl:value -of 
        82       select="su bstring($m sh2, 3, 1)
        83      />
        84              
        85     </xsl:vari able>
        86             
        87     <!-- speci al chars,  like "&",  will be co rrectly ha ndled by t he xml par ser -->
        88             
        89     <xsl:varia ble 
        90      name="subS eparatorMe ssage"
        91     >
        92                       
        93      <xsl:value -of 
        94       select="su bstring($m sh2, 4, 1)
        95      />
        96              
        97     </xsl:vari able>
        98             
        99     <!-- BHS s pecial cha rs -->
        100             
        101     <xsl:varia ble 
        102      name="fiel dSeparator Batch"
        103     >
        104                       
        105      <xsl:value -of 
        106       select="no rmalize-sp ace(//BHS/ BHS.1)" 
        107      />
        108              
        109     </xsl:vari able>
        110             
        111     <xsl:varia ble 
        112      name="bhs2 "
        113     >
        114                       
        115      <xsl:value -of 
        116       select="no rmalize-sp ace(//BHS/ BHS.2)" 
        117      />
        118              
        119     </xsl:vari able>
        120             
        121     <xsl:varia ble 
        122      name="comp SeparatorB atch"
        123     >
        124                       
        125      <xsl:value -of 
        126       select="su bstring($b hs2, 1, 1)
        127      />
        128              
        129     </xsl:vari able>
        130             
        131     <xsl:varia ble 
        132      name="repC harBatch"
        133     >
        134                       
        135      <xsl:value -of 
        136       select="su bstring($b hs2, 2, 1)
        137      />
        138              
        139     </xsl:vari able>
        140             
        141     <xsl:varia ble 
        142      name="esca peCharBatc h"
        143     >
        144                       
        145      <xsl:value -of 
        146       select="su bstring($b hs2, 3, 1)
        147      />
        148              
        149     </xsl:vari able>
        150             
        151     <!-- speci al chars,  like "&",  will be co rrectly ha ndled by t he xml par ser -->
        152             
        153     <xsl:varia ble 
        154      name="subS eparatorBa tch"
        155     >
        156                       
        157      <xsl:value -of 
        158       select="su bstring($b hs2, 4, 1)
        159      />
        160              
        161     </xsl:vari able>
        162             
        163     <!-- FHS s pecial cha rs -->
        164             
        165     <xsl:varia ble 
        166      name="fiel dSeparator File"
        167     >
        168                       
        169      <xsl:value -of 
        170       select="no rmalize-sp ace(//FHS/ FHS.1)" 
        171      />
        172              
        173     </xsl:vari able>
        174             
        175     <xsl:varia ble 
        176      name="fhs2 "
        177     >
        178                       
        179      <xsl:value -of 
        180       select="no rmalize-sp ace(//FHS/ FHS.2)" 
        181      />
        182              
        183     </xsl:vari able>
        184             
        185     <xsl:varia ble 
        186      name="comp SeparatorF ile"
        187     >
        188                       
        189      <xsl:value -of 
        190       select="su bstring($f hs2, 1, 1)
        191      />
        192              
        193     </xsl:vari able>
        194             
        195     <xsl:varia ble 
        196      name="repC harFile"
        197     >
        198                       
        199      <xsl:value -of 
        200       select="su bstring($f hs2, 2, 1)
        201      />
        202              
        203     </xsl:vari able>
        204             
        205     <xsl:varia ble 
        206      name="esca peCharFile "
        207     >
        208                       
        209      <xsl:value -of 
        210       select="su bstring($f hs2, 3, 1)
        211      />
        212              
        213     </xsl:vari able>
        214             
        215     <!-- speci al chars,  like "&",  will be co rrectly ha ndled by t he xml par ser -->
        216             
        217     <xsl:varia ble 
        218      name="subS eparatorFi le"
        219     >
        220                       
        221      <xsl:value -of 
        222       select="su bstring($f hs2, 4, 1)
        223      />
        224              
        225     </xsl:vari able>
        226    
        227             
        228     <!-- start  -->
        229             
        230     <xsl:templ ate 
        231      match="/"
        232     >
        233                       
        234      <xsl:for-e ach 
        235       select="ch ild::*"
        236      >
        237                                 
        238       <xsl:call- template 
        239        name="mess ageType" 
        240       />
        241                        
        242      </xsl:for- each>
        243              
        244     </xsl:temp late>
        245    
        246             
        247     <!-- ..... .message t ype.......  -->
        248             
        249     <xsl:templ ate 
        250      name="mess ageType"
        251     >
        252                       
        253      <!-- proce ss each Se gment or g roup -->
        254                       
        255      <xsl:for-e ach 
        256       select="ch ild::*"
        257      >
        258                                 
        259       <xsl:call- template 
        260        name="segm entOrGroup
        261       />
        262                        
        263      </xsl:for- each>
        264              
        265     </xsl:temp late>
        266    
        267             
        268     <!-- ..... .SegmentOr Group..... .. -->
        269             
        270     <xsl:templ ate 
        271      name="segm entOrGroup "
        272     >
        273                       
        274      <xsl:choos e>
        275                                 
        276       <!-- Segme nt names h ave to be  3 chars. I f the name  is longer  than 3 ch ars, 
        277                                          it shoul d be a gro up name (n ot part of  er7 encod ing) -->
        278                                 
        279       <xsl:when 
        280        test="stri ng-length( local-name ()) &gt; 3 "
        281       >
        282                                           
        283        <xsl:for-e ach 
        284         select="ch ild::*"
        285        >
        286                                                    
        287         <xsl:call- template 
        288          name="segm entOrGroup
        289         />
        290                                            
        291        </xsl:for- each>
        292                                  
        293       </xsl:when >
        294                                 
        295       <xsl:other wise>
        296                                           
        297        <!-- Segme nt -->
        298                                           
        299        <xsl:choos e>
        300                                                    
        301         <xsl:when 
        302          test="coun t(child::* ) &gt; 0"
        303         >
        304                                                              
        305          <xsl:call- template 
        306           name="segm ent" 
        307          />
        308                                                              
        309          <xsl:value -of 
        310           select="$n l" 
        311          />
        312                                                     
        313         </xsl:when >
        314                                            
        315        </xsl:choo se>
        316                                  
        317       </xsl:othe rwise>
        318                        
        319      </xsl:choo se>
        320              
        321     </xsl:temp late>
        322    
        323             
        324     <!-- ..... .Segment.. ..... -->
        325             
        326     <xsl:templ ate 
        327      name="segm ent"
        328     >
        329                       
        330      <xsl:varia ble 
        331       name="segN ame"
        332      >
        333                                 
        334       <xsl:value -of 
        335        select="lo cal-name()
        336       />
        337                        
        338      </xsl:vari able>
        339                       
        340      <!-- dump  Segment na me -->
        341                       
        342      <xsl:value -of 
        343       select="$s egName" 
        344      />
        345     
        346                       
        347      <!-- proce ss each Fi eld -->
        348                       
        349      <xsl:for-e ach 
        350       select="ch ild::*"
        351      >
        352                                 
        353       <xsl:varia ble 
        354        name="fiel dName"
        355       >
        356                                           
        357        <xsl:value -of 
        358         select="lo cal-name()
        359        />
        360                                  
        361       </xsl:vari able>
        362                                 
        363       <!-- name  of immedia te sibling  (siblings  are retur ned in rev erse doc o rder) -->
        364                                 
        365       <xsl:varia ble 
        366        name="sibl ingName"
        367       >
        368                                           
        369        <xsl:value -of 
        370         select="lo cal-name(p receding-s ibling::*[ 1])" 
        371        />
        372                                  
        373       </xsl:vari able>
        374      
        375                                 
        376       <xsl:choos e>
        377                                           
        378        <!-- first  2 Fields  of MSH con tain speci al chars p icked up a bove -->
        379                                           
        380        <xsl:when 
        381         test="$seg Name = 'MS H' and $fi eldName =  'MSH.1'"
        382        >
        383                                                    
        384         <xsl:if
        385                                                             
        386          test="$fie ldSeparato rMessage =  '' or
        387                           $com pSeparator Message =  '' or
        388                           $rep CharMessag e = '' or
        389                           $esc apeCharMes sage = ''  or
        390                           $sub SeparatorM essage = ' '"
        391         >
        392                                                              ** ***ERROR** **
        393                                                              CA NNOT TRANS LATE CORRE CTLY! ONE  OR MORE SP ECIAL CHAR S EMPTY.
        394                                                              ** ***ERROR** **
        395                                                     
        396         </xsl:if>
        397                                                    
        398         <!-- dump  special ch ars -->
        399                                                    
        400         <xsl:value -of 
        401          select="$f ieldSepara torMessage
        402         />
        403                                                    
        404         <xsl:value -of 
        405          select="$c ompSeparat orMessage"  
        406         />
        407                                                    
        408         <xsl:value -of 
        409          select="$r epCharMess age" 
        410         />
        411                                                    
        412         <xsl:value -of 
        413          select="$e scapeCharM essage" 
        414         />
        415                                                    
        416         <xsl:value -of 
        417          select="$s ubSeparato rMessage" 
        418         />
        419                                            
        420        </xsl:when >
        421                                           
        422        <xsl:when 
        423         test="$seg Name = 'MS H' and $fi eldName =  'MSH.2'"
        424        >
        425                                                    
        426         <!-- skip  field -->
        427                                            
        428        </xsl:when >
        429                                           
        430        <!-- first  2 Fields  of BHS con tain speci al chars p icked up a bove -->
        431                                           
        432        <xsl:when 
        433         test="$seg Name = 'BH S' and $fi eldName =  'BHS.1'"
        434        >
        435                                                    
        436         <xsl:if
        437                                                             
        438          test="$fie ldSeparato rBatch = ' ' or
        439                       $compSep aratorBatc h = '' or
        440                       $repChar Batch = ''  or
        441                       $escapeC harBatch =  '' or
        442                       $subSepa ratorBatch  = ''"
        443         >
        444                                                              ** ***ERROR** **
        445                                                              CA NNOT TRANS LATE CORRE CTLY! ONE  OR MORE SP ECIAL CHAR S EMPTY.
        446                                                              ** ***ERROR** **
        447                                                     
        448         </xsl:if>
        449                                                    
        450         <!-- dump  special ch ars -->
        451                                                    
        452         <xsl:value -of 
        453          select="$f ieldSepara torBatch" 
        454         />
        455                                                    
        456         <xsl:value -of 
        457          select="$c ompSeparat orBatch" 
        458         />
        459                                                    
        460         <xsl:value -of 
        461          select="$r epCharBatc h" 
        462         />
        463                                                    
        464         <xsl:value -of 
        465          select="$e scapeCharB atch" 
        466         />
        467                                                    
        468         <xsl:value -of 
        469          select="$s ubSeparato rBatch" 
        470         />
        471                                            
        472        </xsl:when >
        473                                           
        474        <xsl:when 
        475         test="$seg Name = 'BH S' and $fi eldName =  'BHS.2'"
        476        >
        477                                                    
        478         <!-- skip  field -->
        479                                            
        480        </xsl:when >
        481                                           
        482        <!-- first  2 Fields  of FHS con tain speci al chars p icked up a bove -->
        483                                           
        484        <xsl:when 
        485         test="$seg Name = 'FH S' and $fi eldName =  'FHS.1'"
        486        >
        487                                                    
        488         <xsl:if
        489                                                             
        490          test="$fie ldSeparato rFile = ''  or
        491                       $compSep aratorFile  = '' or
        492                       $repChar File = ''  or
        493                       $escapeC harFile =  '' or
        494                       $subSepa ratorFile  = ''"
        495         >
        496                                                              ** ***ERROR** **
        497                                                              CA NNOT TRANS LATE CORRE CTLY! ONE  OR MORE SP ECIAL CHAR S EMPTY.
        498                                                              ** ***ERROR** **
        499                                                     
        500         </xsl:if>
        501                                                    
        502         <!-- dump  special ch ars -->
        503                                                    
        504         <xsl:value -of 
        505          select="$f ieldSepara torFile" 
        506         />
        507                                                    
        508         <xsl:value -of 
        509          select="$c ompSeparat orFile" 
        510         />
        511                                                    
        512         <xsl:value -of 
        513          select="$r epCharFile
        514         />
        515                                                    
        516         <xsl:value -of 
        517          select="$e scapeCharF ile" 
        518         />
        519                                                    
        520         <xsl:value -of 
        521          select="$s ubSeparato rFile" 
        522         />
        523                                            
        524        </xsl:when >
        525                                           
        526        <xsl:when 
        527         test="$seg Name = 'FH S' and $fi eldName =  'FHS.2'"
        528        >
        529                                                    
        530         <!-- skip  field -->
        531                                            
        532        </xsl:when >
        533                                           
        534        <xsl:other wise>
        535           
        536         <!-- if it 's not 1 o f 1st 2 fl ds of MSH,  BHS, or F HS -->
        537                                                    
        538         <!-- flag  batch and  file segme nts -->
        539                                                    
        540         <xsl:varia ble 
        541          name="batc hSegment"
        542         >
        543                                                              
        544          <xsl:choos e>
        545                                                                        
        546           <xsl:when 
        547            test="$seg Name = 'BH S' or $seg Name = 'BT S'"
        548           >
        549                                                                                  
        550            <xsl:value -of 
        551             select="'t rue'" 
        552            />
        553                                                                         
        554           </xsl:when >
        555                                                                        
        556           <xsl:other wise>
        557                                                                                  
        558            <xsl:value -of 
        559             select="'f alse'" 
        560            />
        561                                                                         
        562           </xsl:othe rwise>
        563                                                               
        564          </xsl:choo se>
        565                                                     
        566         </xsl:vari able>
        567                                                    
        568         <xsl:varia ble 
        569          name="file Segment"
        570         >
        571                                                              
        572          <xsl:choos e>
        573                                                                        
        574           <xsl:when 
        575            test="$seg Name = 'FH S' or $seg Name = 'FT S'"
        576           >
        577                                                                                  
        578            <xsl:value -of 
        579             select="'t rue'" 
        580            />
        581                                                                         
        582           </xsl:when >
        583                                                                        
        584           <xsl:other wise>
        585                                                                                  
        586            <xsl:value -of 
        587             select="'f alse'" 
        588            />
        589                                                                         
        590           </xsl:othe rwise>
        591                                                               
        592          </xsl:choo se>
        593                                                     
        594         </xsl:vari able>
        595        
        596                                                    
        597         <!-- set s pecial cha rs to use  -->
        598                                                    
        599         <xsl:varia ble 
        600          name="fiel dSeparator "
        601         >
        602                                                              
        603          <xsl:choos e>
        604                                                                        
        605           <xsl:when 
        606            test="$bat chSegment  = 'true'"
        607           >
        608                                                                                  
        609            <xsl:value -of 
        610             select="$f ieldSepara torBatch" 
        611            />
        612                                                                         
        613           </xsl:when >
        614                                                                        
        615           <xsl:when 
        616            test="$fil eSegment =  'true'"
        617           >
        618                                                                                  
        619            <xsl:value -of 
        620             select="$f ieldSepara torFile" 
        621            />
        622                                                                         
        623           </xsl:when >
        624                                                                        
        625           <xsl:other wise>
        626                                                                                  
        627            <xsl:value -of 
        628             select="$f ieldSepara torMessage
        629            />
        630                                                                         
        631           </xsl:othe rwise>
        632                                                               
        633          </xsl:choo se>
        634                                                     
        635         </xsl:vari able>
        636                                                    
        637         <xsl:varia ble 
        638          name="comp Separator"
        639         >
        640                                                              
        641          <xsl:choos e>
        642                                                                        
        643           <xsl:when 
        644            test="$bat chSegment  = 'true'"
        645           >
        646                                                                                  
        647            <xsl:value -of 
        648             select="$c ompSeparat orBatch" 
        649            />
        650                                                                         
        651           </xsl:when >
        652                                                                        
        653           <xsl:when 
        654            test="$fil eSegment =  'true'"
        655           >
        656                                                                                  
        657            <xsl:value -of 
        658             select="$c ompSeparat orFile" 
        659            />
        660                                                                         
        661           </xsl:when >
        662                                                                        
        663           <xsl:other wise>
        664                                                                                  
        665            <xsl:value -of 
        666             select="$c ompSeparat orMessage"  
        667            />
        668                                                                         
        669           </xsl:othe rwise>
        670                                                               
        671          </xsl:choo se>
        672                                                     
        673         </xsl:vari able>
        674                                                    
        675         <xsl:varia ble 
        676          name="repC har"
        677         >
        678                                                              
        679          <xsl:choos e>
        680                                                                        
        681           <xsl:when 
        682            test="$bat chSegment  = 'true'"
        683           >
        684                                                                                  
        685            <xsl:value -of 
        686             select="$r epCharBatc h" 
        687            />
        688                                                                         
        689           </xsl:when >
        690                                                                        
        691           <xsl:when 
        692            test="$fil eSegment =  'true'"
        693           >
        694                                                                                  
        695            <xsl:value -of 
        696             select="$r epCharFile
        697            />
        698                                                                         
        699           </xsl:when >
        700                                                                        
        701           <xsl:other wise>
        702                                                                                  
        703            <xsl:value -of 
        704             select="$r epCharMess age" 
        705            />
        706                                                                         
        707           </xsl:othe rwise>
        708                                                               
        709          </xsl:choo se>
        710                                                     
        711         </xsl:vari able>
        712                                                    
        713         <xsl:varia ble 
        714          name="esca peChar"
        715         >
        716                                                              
        717          <xsl:choos e>
        718                                                                        
        719           <xsl:when 
        720            test="$bat chSegment  = 'true'"
        721           >
        722                                                                                  
        723            <xsl:value -of 
        724             select="$e scapeCharB atch" 
        725            />
        726                                                                         
        727           </xsl:when >
        728                                                                        
        729           <xsl:when 
        730            test="$fil eSegment =  'true'"
        731           >
        732                                                                                  
        733            <xsl:value -of 
        734             select="$e scapeCharF ile" 
        735            />
        736                                                                         
        737           </xsl:when >
        738                                                                        
        739           <xsl:other wise>
        740                                                                                  
        741            <xsl:value -of 
        742             select="$e scapeCharM essage" 
        743            />
        744                                                                         
        745           </xsl:othe rwise>
        746                                                               
        747          </xsl:choo se>
        748                                                     
        749         </xsl:vari able>
        750                                                    
        751         <xsl:varia ble 
        752          name="subS eparator"
        753         >
        754                                                              
        755          <xsl:choos e>
        756                                                                        
        757           <xsl:when 
        758            test="$bat chSegment  = 'true'"
        759           >
        760                                                                                  
        761            <xsl:value -of 
        762             select="$s ubSeparato rBatch" 
        763            />
        764                                                                         
        765           </xsl:when >
        766                                                                        
        767           <xsl:when 
        768            test="$fil eSegment =  'true'"
        769           >
        770                                                                                  
        771            <xsl:value -of 
        772             select="$s ubSeparato rFile" 
        773            />
        774                                                                         
        775           </xsl:when >
        776                                                                        
        777           <xsl:other wise>
        778                                                                                  
        779            <xsl:value -of 
        780             select="$s ubSeparato rMessage" 
        781            />
        782                                                                         
        783           </xsl:othe rwise>
        784                                                               
        785          </xsl:choo se>
        786                                                     
        787         </xsl:vari able>
        788        
        789                                                    
        790         <!-- get t his Field' s sequence  number -- >
        791                                                    
        792         <xsl:varia ble 
        793          name="fiel dNum"
        794         >
        795                                                              
        796          <xsl:call- template 
        797           name="getT railingNum ber"
        798          >
        799                                                                        
        800           <xsl:with- param 
        801            name="elem entName" 
        802            select="$f ieldName" 
        803           />
        804                                                               
        805          </xsl:call -template>
        806                                                     
        807         </xsl:vari able>
        808        
        809                                                    
        810         <!-- get p revious Fi eld's sequ ence numbe r -->
        811                                                    
        812         <xsl:varia ble 
        813          name="sibl ingNum"
        814         >
        815                                                              
        816          <xsl:choos e>
        817                                                                        
        818           <!-- Field  separator s precede  Field, so  assign 1st  0 -->
        819                                                                        
        820           <xsl:when 
        821            test="$sib lingName =  ''"
        822           >
        823                                                                                  
        824            <xsl:value -of 
        825             select="0"  
        826            />
        827                                                                         
        828           </xsl:when >
        829                                                                        
        830           <xsl:other wise>
        831                                                                                  
        832            <xsl:call- template 
        833             name="getT railingNum ber"
        834            >
        835                                                                                            
        836             <xsl:with- param 
        837              name="elem entName" 
        838              select="$s iblingName
        839             />
        840                                                                                   
        841            </xsl:call -template>
        842                                                                         
        843           </xsl:othe rwise>
        844                                                               
        845          </xsl:choo se>
        846                                                     
        847         </xsl:vari able>
        848        
        849                                                    
        850         <!-- use F ield or re petition s eparator - ->
        851                                                    
        852         <xsl:varia ble 
        853          name="sepa rator"
        854         >
        855                                                              
        856          <xsl:choos e>
        857                                                                        
        858           <xsl:when 
        859            test="$fie ldName = $ siblingNam e"
        860           >
        861                                                                                  
        862            <xsl:value -of 
        863             select="$r epChar" 
        864            />
        865                                                                         
        866           </xsl:when >
        867                                                                        
        868           <xsl:other wise>
        869                                                                                  
        870            <xsl:value -of 
        871             select="$f ieldSepara tor" 
        872            />
        873                                                                         
        874           </xsl:othe rwise>
        875                                                               
        876          </xsl:choo se>
        877                                                     
        878         </xsl:vari able>
        879        
        880                                                    
        881         <!-- if it 's a repea ting Field , have to  repeat sep arator onc e -->
        882                                                    
        883         <xsl:varia ble 
        884          name="sepa ratorReps"
        885         >
        886                                                              
        887          <xsl:choos e>
        888                                                                        
        889           <xsl:when 
        890            test="$sep arator = $ repChar"
        891           >
        892                                                                                  
        893            <xsl:value -of 
        894             select="1"  
        895            />
        896                                                                         
        897           </xsl:when >
        898                                                                        
        899           <xsl:other wise>
        900                
        901            <!-- new F ield -->
        902                                                                                  
        903            <xsl:value -of 
        904             select="$f ieldNum -  $siblingNu m" 
        905            />
        906                                                                         
        907           </xsl:othe rwise>
        908                                                               
        909          </xsl:choo se>
        910                                                     
        911         </xsl:vari able>
        912        
        913                                                    
        914         <!-- add s eparators  -->
        915                                                    
        916         <xsl:call- template 
        917          name="dump Char"
        918         >
        919                                                              
        920          <xsl:with- param 
        921           name="char
        922           select="$s eparator" 
        923          />
        924                                                              
        925          <xsl:with- param 
        926           name="coun t" 
        927           select="$s eparatorRe ps" 
        928          />
        929                                                     
        930         </xsl:call -template>
        931        
        932                                                    
        933         <!-- add F ield after  separator  -->
        934                                                    
        935         <xsl:call- template 
        936          name="fiel d"
        937         >
        938                                                              
        939          <xsl:with- param 
        940           name="fiel dSeparator
        941           select="$f ieldSepara tor" 
        942          />
        943                                                              
        944          <xsl:with- param 
        945           name="comp Separator"  
        946           select="$c ompSeparat or" 
        947          />
        948                                                              
        949          <xsl:with- param 
        950           name="repC har" 
        951           select="$r epChar" 
        952          />
        953                                                              
        954          <xsl:with- param 
        955           name="esca peChar" 
        956           select="$e scapeChar"  
        957          />
        958                                                              
        959          <xsl:with- param 
        960           name="subS eparator" 
        961           select="$s ubSeparato r" 
        962          />
        963                                                     
        964         </xsl:call -template>
        965                                            
        966        </xsl:othe rwise>
        967                                  
        968       </xsl:choo se>
        969                        
        970      </xsl:for- each>
        971              
        972     </xsl:temp late>
        973    
        974             
        975     <!-- ..... .Field.... ... -->
        976             
        977     <xsl:templ ate 
        978      name="fiel d"
        979     >
        980                       
        981      <xsl:param  
        982       name="fiel dSeparator
        983       select="''
        984      />
        985                       
        986      <xsl:param  
        987       name="comp Separator"  
        988       select="''
        989      />
        990                       
        991      <xsl:param  
        992       name="repC har" 
        993       select="''
        994      />
        995                       
        996      <xsl:param  
        997       name="esca peChar" 
        998       select="''
        999      />
        1000                       
        1001      <xsl:param  
        1002       name="subS eparator" 
        1003       select="''
        1004      />
        1005     
        1006                       
        1007      <xsl:choos e>
        1008                                 
        1009       <!-- see i f the Fiel d contains  Component s... -->
        1010                                 
        1011       <xsl:when 
        1012        test="chil d::*"
        1013       >
        1014                                           
        1015        <xsl:for-e ach 
        1016         select="ch ild::*"
        1017        >
        1018                                                    
        1019         <xsl:varia ble 
        1020          name="comp Name"
        1021         >
        1022                                                              
        1023          <xsl:value -of 
        1024           select="lo cal-name()
        1025          />
        1026                                                     
        1027         </xsl:vari able>
        1028                                                    
        1029         <!-- name  of immedia te sibling  (siblings  are retur ned in rev erse doc 
        1030                                                             or der) -->
        1031                                                    
        1032         <xsl:varia ble 
        1033          name="sibl ingName"
        1034         >
        1035                                                              
        1036          <xsl:value -of 
        1037           select="lo cal-name(p receding-s ibling::*[ 1])" 
        1038          />
        1039                                                     
        1040         </xsl:vari able>
        1041        
        1042                                                    
        1043         <!-- Comp  sequence n umber -->
        1044                                                    
        1045         <xsl:varia ble 
        1046          name="comp Num"
        1047         >
        1048                                                              
        1049          <xsl:call- template 
        1050           name="getT railingNum ber"
        1051          >
        1052                                                                        
        1053           <xsl:with- param 
        1054            name="elem entName" 
        1055            select="$c ompName" 
        1056           />
        1057                                                               
        1058          </xsl:call -template>
        1059                                                     
        1060         </xsl:vari able>
        1061        
        1062                                                    
        1063         <!-- immed iate sibli ng of Comp  sequence  number -->
        1064                                                    
        1065         <xsl:varia ble 
        1066          name="sibl ingNum"
        1067         >
        1068                                                              
        1069          <xsl:choos e>
        1070                                                                        
        1071           <!-- Comp  separators  follow Co mp (assign  1 1st to  avoid incl uding 
        1072                                                                                 before  Comp) -->
        1073                                                                        
        1074           <xsl:when 
        1075            test="$sib lingName =  ''"
        1076           >
        1077                                                                                  
        1078            <xsl:value -of 
        1079             select="1"  
        1080            />
        1081                                                                         
        1082           </xsl:when >
        1083                                                                        
        1084           <xsl:other wise>
        1085                                                                                  
        1086            <xsl:call- template 
        1087             name="getT railingNum ber"
        1088            >
        1089                                                                                            
        1090             <xsl:with- param 
        1091              name="elem entName" 
        1092              select="$s iblingName
        1093             />
        1094                                                                                   
        1095            </xsl:call -template>
        1096                                                                         
        1097           </xsl:othe rwise>
        1098                                                               
        1099          </xsl:choo se>
        1100                                                     
        1101         </xsl:vari able>
        1102        
        1103                                                    
        1104         <!-- add c omponent s eparators  -->
        1105                                                    
        1106         <xsl:call- template 
        1107          name="dump Char"
        1108         >
        1109                                                              
        1110          <xsl:with- param 
        1111           name="char
        1112           select="$c ompSeparat or" 
        1113          />
        1114                                                              
        1115          <xsl:with- param 
        1116           name="coun t" 
        1117           select="$c ompNum - $ siblingNum
        1118          />
        1119                                                     
        1120         </xsl:call -template>
        1121        
        1122                                                    
        1123         <!-- add C omponent - ->
        1124                                                    
        1125         <xsl:call- template 
        1126          name="comp onent"
        1127         >
        1128                                                              
        1129          <xsl:with- param 
        1130           name="fiel dSeparator
        1131           select="$f ieldSepara tor" 
        1132          />
        1133                                                              
        1134          <xsl:with- param 
        1135           name="comp Separator"  
        1136           select="$c ompSeparat or" 
        1137          />
        1138                                                              
        1139          <xsl:with- param 
        1140           name="repC har" 
        1141           select="$r epChar" 
        1142          />
        1143                                                              
        1144          <xsl:with- param 
        1145           name="esca peChar" 
        1146           select="$e scapeChar"  
        1147          />
        1148                                                              
        1149          <xsl:with- param 
        1150           name="subS eparator" 
        1151           select="$s ubSeparato r" 
        1152          />
        1153                                                     
        1154         </xsl:call -template>
        1155                                            
        1156        </xsl:for- each>
        1157                                  
        1158       </xsl:when >
        1159                                 
        1160       <xsl:other wise>
        1161          
        1162        <!-- dump  Field valu e -->
        1163                                           
        1164        <xsl:call- template 
        1165         name="dump DataValue"
        1166        >
        1167                                                    
        1168         <xsl:with- param 
        1169          name="data Value" 
        1170          select="st ring()" 
        1171         />
        1172                                                    
        1173         <xsl:with- param 
        1174          name="fiel dSeparator
        1175          select="$f ieldSepara tor" 
        1176         />
        1177                                                    
        1178         <xsl:with- param 
        1179          name="comp Separator"  
        1180          select="$c ompSeparat or" 
        1181         />
        1182                                                    
        1183         <xsl:with- param 
        1184          name="repC har" 
        1185          select="$r epChar" 
        1186         />
        1187                                                    
        1188         <xsl:with- param 
        1189          name="esca peChar" 
        1190          select="$e scapeChar"  
        1191         />
        1192                                                    
        1193         <xsl:with- param 
        1194          name="subS eparator" 
        1195          select="$s ubSeparato r" 
        1196         />
        1197                                            
        1198        </xsl:call -template>
        1199                                  
        1200       </xsl:othe rwise>
        1201                        
        1202      </xsl:choo se>
        1203              
        1204     </xsl:temp late>
        1205    
        1206             
        1207     <!-- ..... .Component ....... -- >
        1208             
        1209     <xsl:templ ate 
        1210      name="comp onent"
        1211     >
        1212                       
        1213      <xsl:param  
        1214       name="fiel dSeparator
        1215       select="''
        1216      />
        1217                       
        1218      <xsl:param  
        1219       name="comp Separator"  
        1220       select="''
        1221      />
        1222                       
        1223      <xsl:param  
        1224       name="repC har" 
        1225       select="''
        1226      />
        1227                       
        1228      <xsl:param  
        1229       name="esca peChar" 
        1230       select="''
        1231      />
        1232                       
        1233      <xsl:param  
        1234       name="subS eparator" 
        1235       select="''
        1236      />
        1237     
        1238                       
        1239      <xsl:choos e>
        1240                                 
        1241       <!-- see i f the Comp onent cont ains SubCo mponents.. . -->
        1242                                 
        1243       <xsl:when 
        1244        test="chil d::*"
        1245       >
        1246                                           
        1247        <xsl:for-e ach 
        1248         select="ch ild::*"
        1249        >
        1250                                                    
        1251         <xsl:varia ble 
        1252          name="subN ame"
        1253         >
        1254                                                              
        1255          <xsl:value -of 
        1256           select="lo cal-name()
        1257          />
        1258                                                     
        1259         </xsl:vari able>
        1260                                                    
        1261         <!-- name  of immedia te sibling  (siblings  are retur ned in rev erse doc 
        1262                                                             or der) -->
        1263                                                    
        1264         <xsl:varia ble 
        1265          name="sibl ingName"
        1266         >
        1267                                                              
        1268          <xsl:value -of 
        1269           select="lo cal-name(p receding-s ibling::*[ 1])" 
        1270          />
        1271                                                     
        1272         </xsl:vari able>
        1273        
        1274                                                    
        1275         <!-- SubCo mp sequenc e number - ->
        1276                                                    
        1277         <xsl:varia ble 
        1278          name="subN um"
        1279         >
        1280                                                              
        1281          <xsl:call- template 
        1282           name="getT railingNum ber"
        1283          >
        1284                                                                        
        1285           <xsl:with- param 
        1286            name="elem entName" 
        1287            select="$s ubName" 
        1288           />
        1289                                                               
        1290          </xsl:call -template>
        1291                                                     
        1292         </xsl:vari able>
        1293        
        1294                                                    
        1295         <!-- SubCo mp sibling 's sequenc e number - ->
        1296                                                    
        1297         <xsl:varia ble 
        1298          name="sibl ingNum"
        1299         >
        1300                                                              
        1301          <xsl:choos e>
        1302                                                                        
        1303           <xsl:when 
        1304            test="$sib lingName =  ''"
        1305           >
        1306                                                                                  
        1307            <xsl:value -of 
        1308             select="1"  
        1309            />
        1310                                                                         
        1311           </xsl:when >
        1312                                                                        
        1313           <xsl:other wise>
        1314                                                                                  
        1315            <xsl:call- template 
        1316             name="getT railingNum ber"
        1317            >
        1318                                                                                            
        1319             <xsl:with- param 
        1320              name="elem entName" 
        1321              select="$s iblingName
        1322             />
        1323                                                                                   
        1324            </xsl:call -template>
        1325                                                                         
        1326           </xsl:othe rwise>
        1327                                                               
        1328          </xsl:choo se>
        1329                                                     
        1330         </xsl:vari able>
        1331        
        1332                                                    
        1333         <!-- add S ubComponen t separato rs -->
        1334                                                    
        1335         <xsl:call- template 
        1336          name="dump Char"
        1337         >
        1338                                                              
        1339          <xsl:with- param 
        1340           name="char
        1341           select="$s ubSeparato r" 
        1342          />
        1343                                                              
        1344          <xsl:with- param 
        1345           name="coun t" 
        1346           select="$s ubNum - $s iblingNum"  
        1347          />
        1348                                                     
        1349         </xsl:call -template>
        1350        
        1351                                                    
        1352         <!-- add S ubComp -->
        1353                                                    
        1354         <xsl:call- template 
        1355          name="subC omponent"
        1356         >
        1357                                                              
        1358          <xsl:with- param 
        1359           name="data Value" 
        1360           select="st ring()" 
        1361          />
        1362                                                              
        1363          <xsl:with- param 
        1364           name="fiel dSeparator
        1365           select="$f ieldSepara tor" 
        1366          />
        1367                                                              
        1368          <xsl:with- param 
        1369           name="comp Separator"  
        1370           select="$c ompSeparat or" 
        1371          />
        1372                                                              
        1373          <xsl:with- param 
        1374           name="repC har" 
        1375           select="$r epChar" 
        1376          />
        1377                                                              
        1378          <xsl:with- param 
        1379           name="esca peChar" 
        1380           select="$e scapeChar"  
        1381          />
        1382                                                              
        1383          <xsl:with- param 
        1384           name="subS eparator" 
        1385           select="$s ubSeparato r" 
        1386          />
        1387                                                     
        1388         </xsl:call -template>
        1389                                            
        1390        </xsl:for- each>
        1391                                  
        1392       </xsl:when >
        1393                                 
        1394       <xsl:other wise>
        1395          
        1396        <!-- add C omponent v alue -->
        1397                                           
        1398        <xsl:call- template 
        1399         name="dump DataValue"
        1400        >
        1401                                                    
        1402         <xsl:with- param 
        1403          name="data Value" 
        1404          select="st ring()" 
        1405         />
        1406                                                    
        1407         <xsl:with- param 
        1408          name="fiel dSeparator
        1409          select="$f ieldSepara tor" 
        1410         />
        1411                                                    
        1412         <xsl:with- param 
        1413          name="comp Separator"  
        1414          select="$c ompSeparat or" 
        1415         />
        1416                                                    
        1417         <xsl:with- param 
        1418          name="repC har" 
        1419          select="$r epChar" 
        1420         />
        1421                                                    
        1422         <xsl:with- param 
        1423          name="esca peChar" 
        1424          select="$e scapeChar"  
        1425         />
        1426                                                    
        1427         <xsl:with- param 
        1428          name="subS eparator" 
        1429          select="$s ubSeparato r" 
        1430         />
        1431                                            
        1432        </xsl:call -template>
        1433                                  
        1434       </xsl:othe rwise>
        1435                        
        1436      </xsl:choo se>
        1437              
        1438     </xsl:temp late>
        1439    
        1440             
        1441     <!-- ..... .SubCompon ent.......  -->
        1442             
        1443     <xsl:templ ate 
        1444      name="subC omponent"
        1445     >
        1446                       
        1447      <xsl:param  
        1448       name="fiel dSeparator
        1449       select="''
        1450      />
        1451                       
        1452      <xsl:param  
        1453       name="comp Separator"  
        1454       select="''
        1455      />
        1456                       
        1457      <xsl:param  
        1458       name="repC har" 
        1459       select="''
        1460      />
        1461                       
        1462      <xsl:param  
        1463       name="esca peChar" 
        1464       select="''
        1465      />
        1466                       
        1467      <xsl:param  
        1468       name="subS eparator" 
        1469       select="''
        1470      />
        1471     
        1472                       
        1473      <!-- add S ubComp val ue -->
        1474                       
        1475      <xsl:call- template 
        1476       name="dump DataValue"
        1477      >
        1478                                 
        1479       <xsl:with- param 
        1480        name="data Value" 
        1481        select="st ring()" 
        1482       />
        1483                                 
        1484       <xsl:with- param 
        1485        name="fiel dSeparator
        1486        select="$f ieldSepara tor" 
        1487       />
        1488                                 
        1489       <xsl:with- param 
        1490        name="comp Separator"  
        1491        select="$c ompSeparat or" 
        1492       />
        1493                                 
        1494       <xsl:with- param 
        1495        name="repC har" 
        1496        select="$r epChar" 
        1497       />
        1498                                 
        1499       <xsl:with- param 
        1500        name="esca peChar" 
        1501        select="$e scapeChar"  
        1502       />
        1503                                 
        1504       <xsl:with- param 
        1505        name="subS eparator" 
        1506        select="$s ubSeparato r" 
        1507       />
        1508                        
        1509      </xsl:call -template>
        1510              
        1511     </xsl:temp late>
        1512    
        1513             
        1514     <!-- pull  number fro m string o f form: st ring.Numbe r -->
        1515             
        1516     <xsl:templ ate 
        1517      name="getT railingNum ber"
        1518     >
        1519                       
        1520      <xsl:param  
        1521       name="elem entName" 
        1522       select="''
        1523      />
        1524                       
        1525      <!-- if we  don't gra b a number , NaN is r eturned. a ll numeric  compariso ns 
        1526                                with N aN return  false, sho uld be wha t we want  -->
        1527                       
        1528      <xsl:value -of 
        1529       select="su bstring-af ter($eleme ntName, '. ')" 
        1530      />
        1531              
        1532     </xsl:temp late>
        1533    
        1534             
        1535     <!-- dump  'char' 'co unt' times  -->
        1536             
        1537     <xsl:templ ate 
        1538      name="dump Char"
        1539     >
        1540                       
        1541      <xsl:param  
        1542       name="char
        1543       select="''
        1544      />
        1545                       
        1546      <xsl:param  
        1547       name="coun t" 
        1548       select="0"  
        1549      />
        1550     
        1551                       
        1552      <xsl:if 
        1553       test="$cou nt &gt; 0"
        1554      >
        1555                                 
        1556       <xsl:value -of 
        1557        select="$c har" 
        1558       />
        1559                                 
        1560       <xsl:call- template 
        1561        name="dump Char"
        1562       >
        1563                                           
        1564        <xsl:with- param 
        1565         name="char
        1566         select="$c har" 
        1567        />
        1568                                           
        1569        <xsl:with- param 
        1570         name="coun t" 
        1571         select="$c ount - 1" 
        1572        />
        1573                                  
        1574       </xsl:call -template>
        1575                        
        1576      </xsl:if>
        1577                       
        1578      <xsl:if 
        1579       test="$cou nt &lt; 0"
        1580      >
        1581                                 
        1582       <xsl:value -of 
        1583        select="$c har" 
        1584       />
        1585                        
        1586      </xsl:if>
        1587              
        1588     </xsl:temp late>
        1589    
        1590             
        1591     <!-- befor e values a re include d in the o utput stre am, they'r e normaliz ed 
        1592                      (lea ding and t railing wh ite space  removed) a nd the spe cial chars  captured 
        1593                      abov e have to  be escaped  when part  of a data  value. -- >
        1594             
        1595     <xsl:templ ate 
        1596      name="dump DataValue"
        1597     >
        1598                       
        1599      <xsl:param  
        1600       name="data Value" 
        1601       select="''
        1602      />
        1603                       
        1604      <xsl:param  
        1605       name="init
        1606       select="'t rue'" 
        1607      />
        1608                       
        1609      <xsl:param  
        1610       name="fiel dSeparator
        1611       select="''
        1612      />
        1613                       
        1614      <xsl:param  
        1615       name="comp Separator"  
        1616       select="''
        1617      />
        1618                       
        1619      <xsl:param  
        1620       name="repC har" 
        1621       select="''
        1622      />
        1623                       
        1624      <xsl:param  
        1625       name="esca peChar" 
        1626       select="''
        1627      />
        1628                       
        1629      <xsl:param  
        1630       name="subS eparator" 
        1631       select="''
        1632      />
        1633     
        1634                       
        1635      <!-- first , normaliz e -->
        1636                       
        1637      <xsl:varia ble 
        1638       name="nval ue"
        1639      >
        1640                                 
        1641       <xsl:value -of 
        1642        select="no rmalize-sp ace($dataV alue)" 
        1643       />
        1644                        
        1645      </xsl:vari able>
        1646     
        1647                       
        1648      <!-- escap e char has  to be esc aped first  (and only  once) -->
        1649                       
        1650      <xsl:varia ble 
        1651       name="ecVa lue"
        1652      >
        1653                                 
        1654       <xsl:choos e>
        1655                                           
        1656        <xsl:when 
        1657         test="$ini t = 'true'  and conta ins($nvalu e, $escape Char)"
        1658        >
        1659                                                    
        1660         <xsl:call- template 
        1661          name="esca peescapeCh ars"
        1662         >
        1663                                                              
        1664          <xsl:with- param 
        1665           name="inSt ring" 
        1666           select="$n value" 
        1667          />
        1668                                                              
        1669          <xsl:with- param 
        1670           name="esca peChar" 
        1671           select="$e scapeChar"  
        1672          />
        1673                                                     
        1674         </xsl:call -template>
        1675                                            
        1676        </xsl:when >
        1677                                           
        1678        <xsl:other wise>
        1679                                                    
        1680         <!-- no ch ange to va lue -->
        1681                                                    
        1682         <xsl:value -of 
        1683          select="$n value" 
        1684         />
        1685                                            
        1686        </xsl:othe rwise>
        1687                                  
        1688       </xsl:choo se>
        1689                        
        1690      </xsl:vari able>
        1691     
        1692                       
        1693      <!-- escap e Field se parator -- >
        1694                       
        1695      <xsl:varia ble 
        1696       name="fsVa lue"
        1697      >
        1698                                 
        1699       <xsl:choos e>
        1700                                           
        1701        <xsl:when 
        1702         test="$fie ldSeparato r and cont ains($ecVa lue, $fiel dSeparator )"
        1703        >
        1704                                                    
        1705         <xsl:varia ble 
        1706          name="newS tring"
        1707         >
        1708                                                              
        1709          <xsl:call- template 
        1710           name="repl aceWithEsc apeSequenc e"
        1711          >
        1712                                                                        
        1713           <xsl:with- param 
        1714            name="inSt ring" 
        1715            select="$e cValue" 
        1716           />
        1717                                                                        
        1718           <xsl:with- param 
        1719            name="newC har" 
        1720            select="'F '" 
        1721           />
        1722                                                                        
        1723           <xsl:with- param 
        1724            name="oldC har" 
        1725            select="$f ieldSepara tor" 
        1726           />
        1727                                                                        
        1728           <xsl:with- param 
        1729            name="esca peChar" 
        1730            select="$e scapeChar"  
        1731           />
        1732                                                               
        1733          </xsl:call -template>
        1734                                                     
        1735         </xsl:vari able>
        1736                                                    
        1737         <!-- there  may be ad ditional f ieldSepart ors to esc ape -->
        1738                                                    
        1739         <xsl:call- template 
        1740          name="dump DataValue"
        1741         >
        1742                                                              
        1743          <xsl:with- param 
        1744           name="data Value" 
        1745           select="$n ewString" 
        1746          />
        1747                                                              
        1748          <xsl:with- param 
        1749           name="init
        1750           select="'f alse'" 
        1751          />
        1752                                                              
        1753          <xsl:with- param 
        1754           name="fiel dSeparator
        1755           select="$f ieldSepara tor" 
        1756          />
        1757                                                              
        1758          <xsl:with- param 
        1759           name="comp Separator"  
        1760           select="''
        1761          />
        1762                                                              
        1763          <xsl:with- param 
        1764           name="repC har" 
        1765           select="''
        1766          />
        1767                                                              
        1768          <xsl:with- param 
        1769           name="esca peChar" 
        1770           select="$e scapeChar"  
        1771          />
        1772                                                              
        1773          <xsl:with- param 
        1774           name="subS eparator" 
        1775           select="''
        1776          />
        1777                                                     
        1778         </xsl:call -template>
        1779                                            
        1780        </xsl:when >
        1781                                           
        1782        <xsl:other wise>
        1783                                                    
        1784         <!-- no ch ange to va lue -->
        1785                                                    
        1786         <xsl:value -of 
        1787          select="$e cValue" 
        1788         />
        1789                                            
        1790        </xsl:othe rwise>
        1791                                  
        1792       </xsl:choo se>
        1793                        
        1794      </xsl:vari able>
        1795     
        1796                       
        1797      <!-- escap e Componen t separato r -->
        1798                       
        1799      <xsl:varia ble 
        1800       name="csVa lue"
        1801      >
        1802                                 
        1803       <xsl:choos e>
        1804                                           
        1805        <xsl:when 
        1806         test="$com pSeparator  and conta ins($fsVal ue, $compS eparator)"
        1807        >
        1808                                                    
        1809         <xsl:varia ble 
        1810          name="newS tring"
        1811         >
        1812                                                              
        1813          <xsl:call- template 
        1814           name="repl aceWithEsc apeSequenc e"
        1815          >
        1816                                                                        
        1817           <xsl:with- param 
        1818            name="inSt ring" 
        1819            select="$f sValue" 
        1820           />
        1821                                                                        
        1822           <xsl:with- param 
        1823            name="newC har" 
        1824            select="'S '" 
        1825           />
        1826                                                                        
        1827           <xsl:with- param 
        1828            name="oldC har" 
        1829            select="$c ompSeparat or" 
        1830           />
        1831                                                                        
        1832           <xsl:with- param 
        1833            name="esca peChar" 
        1834            select="$e scapeChar"  
        1835           />
        1836                                                               
        1837          </xsl:call -template>
        1838                                                     
        1839         </xsl:vari able>
        1840                                                    
        1841         <!-- there  may be ad ditional c omp separt ors to esc ape -->
        1842                                                    
        1843         <xsl:call- template 
        1844          name="dump DataValue"
        1845         >
        1846                                                              
        1847          <xsl:with- param 
        1848           name="data Value" 
        1849           select="$n ewString" 
        1850          />
        1851                                                              
        1852          <xsl:with- param 
        1853           name="init
        1854           select="'f alse'" 
        1855          />
        1856                                                              
        1857          <xsl:with- param 
        1858           name="fiel dSeparator
        1859           select="''
        1860          />
        1861                                                              
        1862          <xsl:with- param 
        1863           name="comp Separator"  
        1864           select="$c ompSeparat or" 
        1865          />
        1866                                                              
        1867          <xsl:with- param 
        1868           name="repC har" 
        1869           select="''
        1870          />
        1871                                                              
        1872          <xsl:with- param 
        1873           name="esca peChar" 
        1874           select="$e scapeChar"  
        1875          />
        1876                                                              
        1877          <xsl:with- param 
        1878           name="subS eparator" 
        1879           select="''
        1880          />
        1881                                                     
        1882         </xsl:call -template>
        1883                                            
        1884        </xsl:when >
        1885                                           
        1886        <xsl:other wise>
        1887                                                    
        1888         <!-- no ch ange to va lue -->
        1889                                                    
        1890         <xsl:value -of 
        1891          select="$f sValue" 
        1892         />
        1893                                            
        1894        </xsl:othe rwise>
        1895                                  
        1896       </xsl:choo se>
        1897                        
        1898      </xsl:vari able>
        1899     
        1900                       
        1901      <!-- escap e SubCompo nent separ ator -->
        1902                       
        1903      <xsl:varia ble 
        1904       name="ssVa lue"
        1905      >
        1906                                 
        1907       <xsl:choos e>
        1908                                           
        1909        <xsl:when 
        1910         test="$sub Separator  and contai ns($csValu e, $subSep arator)"
        1911        >
        1912                                                    
        1913         <xsl:varia ble 
        1914          name="newS tring"
        1915         >
        1916                                                              
        1917          <xsl:call- template 
        1918           name="repl aceWithEsc apeSequenc e"
        1919          >
        1920                                                                        
        1921           <xsl:with- param 
        1922            name="inSt ring" 
        1923            select="$c sValue" 
        1924           />
        1925                                                                        
        1926           <xsl:with- param 
        1927            name="newC har" 
        1928            select="'T '" 
        1929           />
        1930                                                                        
        1931           <xsl:with- param 
        1932            name="oldC har" 
        1933            select="$s ubSeparato r" 
        1934           />
        1935                                                                        
        1936           <xsl:with- param 
        1937            name="esca peChar" 
        1938            select="$e scapeChar"  
        1939           />
        1940                                                               
        1941          </xsl:call -template>
        1942                                                     
        1943         </xsl:vari able>
        1944                                                    
        1945         <!-- there  may be ad ditional s ubcomp sep artors to  escape -->
        1946                                                    
        1947         <xsl:call- template 
        1948          name="dump DataValue"
        1949         >
        1950                                                              
        1951          <xsl:with- param 
        1952           name="data Value" 
        1953           select="$n ewString" 
        1954          />
        1955                                                              
        1956          <xsl:with- param 
        1957           name="init
        1958           select="'f alse'" 
        1959          />
        1960                                                              
        1961          <xsl:with- param 
        1962           name="fiel dSeparator
        1963           select="''
        1964          />
        1965                                                              
        1966          <xsl:with- param 
        1967           name="comp Separator"  
        1968           select="''
        1969          />
        1970                                                              
        1971          <xsl:with- param 
        1972           name="repC har" 
        1973           select="''
        1974          />
        1975                                                              
        1976          <xsl:with- param 
        1977           name="esca peChar" 
        1978           select="$e scapeChar"  
        1979          />
        1980                                                              
        1981          <xsl:with- param 
        1982           name="subS eparator" 
        1983           select="$s ubSeparato r" 
        1984          />
        1985                                                     
        1986         </xsl:call -template>
        1987                                            
        1988        </xsl:when >
        1989                                           
        1990        <xsl:other wise>
        1991                                                    
        1992         <!-- no ch ange to va lue -->
        1993                                                    
        1994         <xsl:value -of 
        1995          select="$c sValue" 
        1996         />
        1997                                            
        1998        </xsl:othe rwise>
        1999                                  
        2000       </xsl:choo se>
        2001                        
        2002      </xsl:vari able>
        2003     
        2004                       
        2005      <!-- escap e repetiti on char -- >
        2006                       
        2007      <xsl:varia ble 
        2008       name="rcVa lue"
        2009      >
        2010                                 
        2011       <xsl:choos e>
        2012                                           
        2013        <xsl:when 
        2014         test="$rep Char and c ontains($s sValue, $r epChar)"
        2015        >
        2016                                                    
        2017         <xsl:varia ble 
        2018          name="newS tring"
        2019         >
        2020                                                              
        2021          <xsl:call- template 
        2022           name="repl aceWithEsc apeSequenc e"
        2023          >
        2024                                                                        
        2025           <xsl:with- param 
        2026            name="inSt ring" 
        2027            select="$s sValue" 
        2028           />
        2029                                                                        
        2030           <xsl:with- param 
        2031            name="newC har" 
        2032            select="'R '" 
        2033           />
        2034                                                                        
        2035           <xsl:with- param 
        2036            name="oldC har" 
        2037            select="$r epChar" 
        2038           />
        2039                                                                        
        2040           <xsl:with- param 
        2041            name="esca peChar" 
        2042            select="$e scapeChar"  
        2043           />
        2044                                                               
        2045          </xsl:call -template>
        2046                                                     
        2047         </xsl:vari able>
        2048                                                    
        2049         <!-- there  may be ad ditional r ep chars t o escape - ->
        2050                                                    
        2051         <xsl:call- template 
        2052          name="dump DataValue"
        2053         >
        2054                                                              
        2055          <xsl:with- param 
        2056           name="data Value" 
        2057           select="$n ewString" 
        2058          />
        2059                                                              
        2060          <xsl:with- param 
        2061           name="init
        2062           select="'f alse'" 
        2063          />
        2064                                                              
        2065          <xsl:with- param 
        2066           name="fiel dSeparator
        2067           select="''
        2068          />
        2069                                                              
        2070          <xsl:with- param 
        2071           name="comp Separator"  
        2072           select="''
        2073          />
        2074                                                              
        2075          <xsl:with- param 
        2076           name="repC har" 
        2077           select="$r epChar" 
        2078          />
        2079                                                              
        2080          <xsl:with- param 
        2081           name="esca peChar" 
        2082           select="$e scapeChar"  
        2083          />
        2084                                                              
        2085          <xsl:with- param 
        2086           name="subS eparator" 
        2087           select="''
        2088          />
        2089                                                     
        2090         </xsl:call -template>
        2091                                            
        2092        </xsl:when >
        2093                                           
        2094        <xsl:other wise>
        2095                                                    
        2096         <!-- no ch ange to va lue -->
        2097                                                    
        2098         <xsl:value -of 
        2099          select="$s sValue" 
        2100         />
        2101                                            
        2102        </xsl:othe rwise>
        2103                                  
        2104       </xsl:choo se>
        2105                        
        2106      </xsl:vari able>
        2107     
        2108                       
        2109      <!-- retur n new valu e -->
        2110                       
        2111      <xsl:value -of 
        2112       select="$r cValue" 
        2113      />
        2114              
        2115     </xsl:temp late>
        2116    
        2117             
        2118     <!-- escap e escape c haracters  in input s tring. -->
        2119             
        2120     <xsl:templ ate 
        2121      name="esca peescapeCh ars"
        2122     >
        2123                       
        2124      <xsl:param  
        2125       name="inSt ring" 
        2126       select="''
        2127      />
        2128                       
        2129      <xsl:param  
        2130       name="esca peChar" 
        2131       select="''
        2132      />
        2133                       
        2134      <xsl:varia ble 
        2135       name="proc essedStrin g"
        2136      >
        2137                                 
        2138       <xsl:if 
        2139        test="cont ains($inSt ring, $esc apeChar)"
        2140       >
        2141                                           
        2142        <!-- split  input str ing into h ead and ta il -->
        2143                                           
        2144        <xsl:varia ble 
        2145         name="head "
        2146                                                   
        2147         select="co ncat(subst ring-befor e($inStrin g, '\'), ' \')" 
        2148        />
        2149                                           
        2150        <xsl:varia ble 
        2151         name="tail
        2152         select="su bstring-af ter($inStr ing, '\')"  
        2153        />
        2154                                           
        2155        <!-- proce ss head -- >
        2156                                           
        2157        <xsl:varia ble 
        2158         name="esca pedString"
        2159        >
        2160                                                    
        2161         <xsl:call- template 
        2162          name="repl aceWithEsc apeSequenc e"
        2163         >
        2164                                                              
        2165          <xsl:with- param 
        2166           name="inSt ring" 
        2167           select="$h ead" 
        2168          />
        2169                                                              
        2170          <xsl:with- param 
        2171           name="newC har" 
        2172           select="'E '" 
        2173          />
        2174                                                              
        2175          <xsl:with- param 
        2176           name="oldC har" 
        2177           select="$e scapeChar"  
        2178          />
        2179                                                              
        2180          <xsl:with- param 
        2181           name="esca peChar" 
        2182           select="$e scapeChar"  
        2183          />
        2184                                                     
        2185         </xsl:call -template>
        2186                                            
        2187        </xsl:vari able>
        2188       
        2189                                           
        2190        <!-- set v alue to va lue of esc aped strin g and appe nd tail if  it doesn'
        2191                                                    contain an y escape c hars -->
        2192                                           
        2193        <xsl:choos e>
        2194                                                    
        2195         <xsl:when 
        2196          test="cont ains($tail , $escapeC har)"
        2197         >
        2198                                                              
        2199          <xsl:value -of 
        2200           select="$e scapedStri ng" 
        2201          />
        2202                                                     
        2203         </xsl:when >
        2204                                                    
        2205         <xsl:other wise>
        2206                                                              
        2207          <xsl:value -of 
        2208           select="co ncat($esca pedString,  $tail)" 
        2209          />
        2210                                                     
        2211         </xsl:othe rwise>
        2212                                            
        2213        </xsl:choo se>
        2214       
        2215                                           
        2216        <xsl:call- template 
        2217         name="esca peescapeCh ars"
        2218        >
        2219                                                    
        2220         <xsl:with- param 
        2221          name="inSt ring" 
        2222          select="$t ail" 
        2223         />
        2224                                                    
        2225         <xsl:with- param 
        2226          name="esca peChar" 
        2227          select="$e scapeChar"  
        2228         />
        2229                                            
        2230        </xsl:call -template>
        2231                                  
        2232       </xsl:if>
        2233                        
        2234      </xsl:vari able>
        2235     
        2236                       
        2237      <!-- dump  value -->
        2238                       
        2239      <xsl:choos e>
        2240                                 
        2241       <!-- proce ssed strin g should b e empty if  no escape  chars in  input stri ng -->
        2242                                 
        2243       <xsl:when 
        2244        test="$pro cessedStri ng = ''"
        2245       >
        2246                                           
        2247        <!-- <xsl: value-of s elect="$in String"/>  -->
        2248                                  
        2249       </xsl:when >
        2250                                 
        2251       <xsl:other wise>
        2252                                           
        2253        <xsl:value -of 
        2254         select="$p rocessedSt ring" 
        2255        />
        2256                                  
        2257       </xsl:othe rwise>
        2258                        
        2259      </xsl:choo se>
        2260              
        2261     </xsl:temp late>
        2262    
        2263             
        2264     <!-- repla ce first o ccurrance  of 'oldCha r' in 'inS tring' wit h 'escapeS tring' 
        2265                      (use  'newChar'  to build  escapeStri ng) -->
        2266             
        2267     <xsl:templ ate 
        2268      name="repl aceWithEsc apeSequenc e"
        2269     >
        2270                       
        2271      <xsl:param  
        2272       name="inSt ring" 
        2273       select="''
        2274      />
        2275                       
        2276      <xsl:param  
        2277       name="newC har" 
        2278       select="''
        2279      />
        2280                       
        2281      <xsl:param  
        2282       name="oldC har" 
        2283       select="''
        2284      />
        2285                       
        2286      <xsl:param  
        2287       name="esca peChar" 
        2288       select="''
        2289      />
        2290     
        2291                       
        2292      <xsl:varia ble 
        2293       name="esca peString"
        2294      >
        2295                                 
        2296       <xsl:value -of 
        2297        select="$e scapeChar"  
        2298       />
        2299                                 
        2300       <xsl:value -of 
        2301        select="$n ewChar" 
        2302       />
        2303                                 
        2304       <xsl:value -of 
        2305        select="$e scapeChar"  
        2306       />
        2307                        
        2308      </xsl:vari able>
        2309     
        2310                       
        2311      <xsl:varia ble 
        2312       name="newS tringHead"
        2313                                
        2314       select="su bstring-be fore($inSt ring, $old Char)" 
        2315      />
        2316                       
        2317      <xsl:varia ble 
        2318       name="newS tringTail"  
        2319       select="su bstring-af ter($inStr ing, $oldC har)" 
        2320      />
        2321     
        2322                       
        2323      <!-- retur n new stri ng -->
        2324                       
        2325      <xsl:value -of 
        2326       select="co ncat($newS tringHead,  $escapeSt ring, $new StringTail )" 
        2327      />
        2328              
        2329     </xsl:temp late>
        2330    
        2331   </xsl:styl esheet>