[xsl] convert large array to several smaller arrays containing max N elements

Subject: [xsl] convert large array to several smaller arrays containing max N elements
From: David Everly <deckrider@xxxxxxxxxxxxx>
Date: Tue, 11 Nov 2003 15:14:48 -0700
Using Xalan-C 1.6, I am wanting to convert an array of any size to
smaller arrays, each with a max of N elements.  Logically, I think
this can work, but there is something I'm missing with respect to
how/when validation occurs.

The problem is, with the following, I get validation errors:

$  Xalan -i 3  in.xml rules.xsl 

Fatal Error at (file deverly.xsl, line 12, column 20): Expected end of tag 'xsl:if'
SAXParseException: Expected end of tag 'xsl:if' (deverly.xsl, line 12, column 20)

Any assistance would be appreciated.

Thanks,
Dave.
===begin XSL===
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match="/">
   <topgroup>
   <xsl:for-each select="//WorkOrder/lineService">
      <TEABTN>
         <NPA><xsl:value-of select="normalize-space(tpExistAcctBillTelNo/npa)"/></NPA>
         <NXX><xsl:value-of select="normalize-space(tpExistAcctBillTelNo/nxx)"/></NXX>
         <XXXX><xsl:value-of select="normalize-space(tpExistAcctBillTelNo/xxxx)"/></XXXX>
      </TEABTN>
      <xsl:if test="position() mod 2 = '0'">
         </topgroup>
         <topgroup>
      </xsl:if>
   </xsl:for-each>
   </topgroup>
</xsl:template>
</xsl:stylesheet>
===end XSL===
===begin sample XML===
<?xml version="1.0" encoding="UTF-8"?>
<WorkOrder>

<svcReqstId> 156789 </svcReqstId>
<sourceSys>OSS</sourceSys>
<primaryTp>
        <tpId> VRZ </tpId>
        <tpState> NY </tpState>
        <tpSvcCenterCd> NY </tpSvcCenterCd>
</primaryTp>
<contact>
        <contactMethod>
                <contactType> PAGER </contactType>
                <emailAddr> xxx+page@@yy.zz </emailAddr>
        </contactMethod>
        <contactMethod>
                <contactType> email </contactType>
                <emailAddr> xxx@@yy.zz </emailAddr>
        </contactMethod>
</contact>
<lineService>
        <lineRefNum> XY13</lineRefNum>
        <reqstDelivDueDate>11/20/03 14:30:06 </reqstDelivDueDate>
        <lineProductCode> NP</lineProductCode>
        <numProtabilityId> N23 </numProtabilityId>

        <portedTelNo>
                <npa> 888 </npa>
                <nxx>858 </nxx>
                <xxxx> 9988 </xxxx>
        </portedTelNo>
        <tpExistAcctBillTelNo>
                <npa> 703 </npa>
                <nxx>858 </nxx>
                <xxxx> 9988 </xxxx>
        </tpExistAcctBillTelNo>
</lineService>
<lineService>
        <lineRefNum> XY14</lineRefNum>
        <reqstDelivDueDate>11/20/03 14:30:06 </reqstDelivDueDate>
        <lineProductCode> NP</lineProductCode>
        <numProtabilityId> N23 </numProtabilityId>

        <portedTelNo>
                <npa> 888 </npa>
                <nxx>858 </nxx>
                <xxxx> 9988 </xxxx>
        </portedTelNo>
        <tpExistAcctBillTelNo>
                <npa> 703 </npa>
                <nxx>858 </nxx>
                <xxxx> 9989 </xxxx>
        </tpExistAcctBillTelNo>
</lineService>
<lineService>
        <lineRefNum> XY15</lineRefNum>
        <reqstDelivDueDate>11/20/03 14:30:06 </reqstDelivDueDate>
        <lineProductCode> NP</lineProductCode>
        <numProtabilityId> N24 </numProtabilityId>

        <portedTelNo>
                <npa> 888 </npa>
                <nxx>111 </nxx>
                <xxxx> 9988 </xxxx>
        </portedTelNo>
        <tpExistAcctBillTelNo>
                <npa> 403 </npa>
                <nxx>858 </nxx>
                <xxxx> 4988 </xxxx>
        </tpExistAcctBillTelNo>
</lineService>
</WorkOrder>

===end sample XML===
-- 
()  ASCII ribbon campaign - against HTML email
/\                        - against Microsoft attachments

For assistance, see:  http://www.expita.com/nomime.html

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


Current Thread