xsl-list
[Top] [All Lists]

RE: Update Variables...

2003-04-14 15:38:29
I'm not sure I understand your problem but have you tried something like 
(untested code):

<xsl:variable name="diag_num" 
select="count(preceding::diagcode1|preceding::diagcode2|preceding::diagcode3)+1"
 />

or 

<xsl:variable name="diag_num" 
select="count(preceding::diagcode1[text()!='']|preceding::diagcode2[text()!='']|preceding::diagcode3[text()!=''])+1"
 />

if the null entries are included in the XML file.  This will give you the 
number of diagcode[1-3] in the document including your current entry.

Depending on whether you want the restart the counter at any point, you may 
need to use the preceding-sibling rather preceding axis.

HTH,

Ken Ross
Ph: +61 7 32359370
Mob: +61 (0)419 772299
Email: Ken(_dot_)Ross(_at_)iie(_dot_)qld(_dot_)gov(_dot_)au


-----Original Message-----
From: McCown, Sean [mailto:Sean(_dot_)McCown(_at_)tenethealth(_dot_)com]
Sent: Tuesday, 15 April 2003 6:09 AM
To: XSL-List(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Update Variables...


 
 
Hi gang, im new to this list and have something I'd like to run by you guys...
 
Im doing an xml project where I have to populate 8,000 xml files with a sql 
query... each file will contain a separate record... this is for a government 
transmission...  so I have a .net program written in vb.net that queries the 
sql server, and creates the .xml files... ive also attached my .xsl to the 
program, so when the resultset creates the .xml file it pumps it through the 
.xsl first and puts it in the format I need...
 
Heres the problem... 
 
 
I have to increment the row-number in the 'detail' tags, and theyre not all 
going to be used... heres what I mean...
 
I have diagnosis codes 1-15... I need to submit all of the ones we're capturing 
in the db... so diagcode1 = 4012.3, diagcode2 = 4569.09, diagcode3 = 4465.34, 
etc...
 
And their row-numbers would be 1-3 respectively...
 
 
 
And each one has a row-number that has to be incremented... the problem is that 
not all the diag codes are populated... so, diagcode 2 may be NULL, and that 
would leave the row-number of diagcode3 to be 2 instead of 3...
 
The sample code is below... youll notice that ive put them in when clauses... 
that's to weed out the nulls... if it's null, I wont build a 'detail' tag for 
it, but I need a way to put the right-row number should one field be null...
 
So, out of diag codes 1-15 in the resultset, I may only have 7 actual codes... 
and the row-number in the output needs to be 1-7, not 1,2,4,8,9 10, etc...
 
 
 
Ive got a variable 'diagvar' to populate the row number because it cant be 
hard-coded because of the nulls... 
 
 
 
There are going to be 15 of these exact code segments, and the way I see it, it 
would just update the diagvar by one each time... like I said, if there were no 
NULLS, it would be easy to do... but since there are, then I don't know what to 
do... it would be a small miracle if I didn't have to use saxon... cause id 
rather not...
 
Remember, this is being populated from a query, not another xml file...
 
 
 
Thanks so much ...
 
Sean.
 
   <xsl:variable name="diagvar">
0
</xsl:variable>
    
 
 
        <xsl:variable name="ICD9CM_Other_Diag_Code1">
       <xsl:value-of select="ICD9CM_Other_Diag_Code1"/>
      </xsl:variable>    
    
 
<xsl:choose>
 
      <xsl:when test="$ICD9CM_Other_Diag_Code1!=''">
 
            <detail>
 
                  <xsl:attribute name="row-number">
       <xsl:value-of select="$diagvar"/>
       </xsl:attribute>
        
       <answer-value>
       <xsl:value-of select="ICD9CM_Other_Diag_Code1"/>
                  </answer-value>
            </detail>
      </xsl:when>
</xsl:choose>
                         
 
 
                  
 
 
 
 
 
 
 
                  
 
            
                  
                  
 
 
                  
 
                  
 
 
                  
 
 
 
 
 
 
 
 
 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Disclaimer:
 
IMPORTANT: This email (including any attachments) may contain confidential,
private or legally privileged information and may be protected by copyright. 
You may
only use it if you are the person(s) it was intended to be sent to and if you 
use it in an
authorised way. No one is allowed to use, review, alter, transmit, disclose, 
distribute,
print or copy this e-mail without appropriate authority.
 
If this e-mail was not intended for you and was sent to you by mistake, please
telephone or e-mail me immediately, destroy any hard copies of this e-mail and 
delete
it and any copies of it from your computer system. Any legal privilege and 
confidentiality attached to this e-mail is not waived or destroyed by that 
mistake.
 
It is your responsibility to ensure that this e-mail does not contain and is 
not affected
by computer viruses, defects or interference by third parties or replication 
problems
(including incompatibility with your computer system).


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>