xpath - Pagination in XSLT -


my request below . empnumberlist have 250 empnumbers separated space.

<soapenv:body>            <v1:mrrequestparam>         <v1:empnumberlist><v1:empnumber>    9989071005 2004421004</v1:empnumber></v1:empnumberlist>      </v1:mrrequestparam>        </soapenv:body> 

the xslt need write should count empnumbers empnumberslist need call stored procedure in xslt such make 5 calls . in 1 call pass 50 empnumbers. make 5 calls in total

first call have $empnumber1 such contains 50 empnumbers

$empnumber1 =     9989071005    2004421004 (so on 50 empnumbers)  <argument type="sql_varchar" mode="input" nullable="true" precision="0" scale="0" isnull="false"><xsl:value-of select="$empnumber1" /> </argument> 

when send response need club 5 result set , send @ time. please let me know if have suggestions

this 1 easy:

use:

string-length(translate(normalize-space(/*/*/*/v1:empnumber), '0123456789',''))+1 

when applied on document (the provided 1 one more number):

<soapenv:body xmlns:soapenv="my:soapenv">     <v1:mrrequestparam xmlns:v1="my:v1">         <v1:empnumberlist>             <v1:empnumber>    9989071005 2004421004 1234567890 </v1:empnumber>         </v1:empnumberlist>     </v1:mrrequestparam> </soapenv:body> 

the wanted, correct result returned:

3 

here complete xslt 1.0 stylesheet run , verify correct results produced:

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"  xmlns:soapenv="my:soapenv" xmlns:v1="my:v1">  <xsl:output method="text"/>      <xsl:template match="/">       <xsl:value-of select=       "string-length(             translate(normalize-space(/*/*/*/v1:empnumber), '0123456789','')                      )+1"/>     </xsl:template> </xsl:stylesheet> 

do note: have specify correct namespaces in transformation , in xml document -- haven't provided them in question.

explanation:

the meaning of expression:

      string-length(             translate(normalize-space(/*/*/*/v1:empnumber), '0123456789','')                      )+1 

is:

  1. normalize-space() . takes string , produces new string it, in leading , trailing whitespace characters deleted.

  2. what remains numbers 1 intermediate space character between every 2 numbers. so, if there n numbers, number of spaces n-1.

  3. the translate() function referenced in expression, returns new string in digits gone (replaced empty string ''. remains space characters.

  4. using string-length() function count of spaces** (n-1). add 1 , number n of numbers in string.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -