Xsl:param or xsl:variable gets reset.

Hi, I'm trying to keep a counter using a top level variable in xsl.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="rownumber">1</xsl:variable>
And every time my xsl calls a specific template, i want to keep a counter.
<xsl:template match="row">
<xsl:variable name="rownumber">     
<xsl:number value="$rownumber+1"/>     
</xsl:variable>     
<xsl:variable value="$rownumber"/>
</xsl:template>
However, my variable $rownumber always gets reset to the default value of "1" everytime the template is called and returns a value of "2".
Is there a work around for this? Is there a way to keep a counter in xsl? Can top level variable change?
I don't want to count the nodes either....
Thanks in advanced,
jon

You can't do that. Variables can't change. And there is no "workaround", as you put it. XSLT is not that kind of programming language. If you want to count something, you need to figure out an expression that looks at the incoming XML and determines the answer. This is often surprisingly easy once you stop writing programs that assume that statements are executed one after the other. For example, in your case it appears that you just want to count the number of "row" elements in the document. The XPath expression for that is "count(//row)". Or perhaps you want to count the number of "row" elements below the current node; that's "count(row)".

Similar Messages

  • Session variable getting reset when leaving dashboard

    I have created a session variable with the 'Enable any user to set the value' option.  I'm using the session variable as the default for a dashboard prompt.  I'm able to set the variable with that  dasboard prompt, and I can confirm that it is indeed getting set properly.  So the interaction of the variable and the prompt seems to be in order.
    After I make a selection from the dashboard prompt, as long as I stay in the dashboard, the session variable stays set to my selection.  I can move from page to page and everything is fine.  The selection stays put as I have set it.  However, the moment I leave the dashboard, the session variable is reinitialized back to its default value as specified by the SQL in its initialization block.  I can go from dashboard to catalog and back to dashboard - boom, it's back to the default.  My selection has been replaced.  ???
    And here's an odd thing:  I can look in the query log and see the initialization block code getting run when I log in.  So far, so good.  I can run the dashboard, make a prompt selection, and see the query log updated just fine.  Still OK.  BUT... when I switch from dashboard to catalog and back to dashboard, the value of the session variable is reset (I see the default month in my analysis and as the prompt default upon redisplay of the dashboard page), but there's no indication in the query log that the initialization block SQL ran again.  The last SQL in the query log still shows my "selected" value in the SQL.  The dashboard page is showing the "default", while the last entry in the query log shows the "selected".
    Can anyone else confirm this odd behavior?  And is there a reason that a session variable should not retain its value throughout the session?  I've always viewed session variables as little buckets of single-cell data whose contents are consistent and static for the duration of a session, unless manually changed by a dashboard prompt.  If the behavior that I'm seeing is both replicatable and expected, it would appear that my understanding is flawed.
    Running 11.1.1.7.0 on Windows Server 2008.  Same behavior is occurring in both Firefox 21 and IE 9.

    Thank you for your answer MK,
    I try to write a SQL in my prompt but not work for me:
    -In default selection I choose SQL Results and I type: Year(Current_date) and save my prompt and I don't see any value in my dashboardpage, if I click in prompt I can see all members of my year dimension but by default is empty.
    I modify the other solution: I have 1hour refresh time and I change for 1 minute, but doesn't work.
    the default initializer is in RPD (variable year that belongs to BI_Year Block) and I have written 2009.

  • How to get xsql page-param on xsl transform?

    On the xsql file a page-param is set. If param does not exist then have do insert new record into master table, then requery for the value to set-page-param.
    How do call the page-param on xsl transform file used in xsql:insert-request?
    <xsql:set-page-param bind-params="cwMedRecNo" name="org_client_id">
    select client_id from org_client
    where chart_number = ?
    and active_ind = 'Y'
    and provider_organization_id = 71
    </xsql:set-page-param>
    <xsql:if-param name="org_client_id" exists="no">
    <!-- Client_Id doesn't exist, get next sequence number value-->
    <xsql:set-page-param name="org_client_id">
    select client_id_s.nextval from dual
    </xsql:set-page-param>
    <!--insert patient into org_client table-->
    <xsql:dml bind-params="org_client_id cwMedRecNo" commit="yes">
    insert into client (organization_id, client_id, chart_number, active_ind, last_updated_date, administered_ind)
    values
    (000, ?, ?, 'Y', sysdate, 'Y')
    </xsql:dml>
    </xsql:if-param>
    <xsql:set-page-param name="s_org_client_id" value="{@org_client_id}" />
    <xsql:insert-request
    table="immunization"
    columns="client_id organization_id site_id vaccination_date last_updated_date entered_by_org_id vaccine_id source_id contraindication_code refused_code elsewhere_code active_record HISTORICAL_IND"
    transform="dme_data_entry_immunization.xsl"
    commit-batch-size = "1" />
    In the dme_data_entry_immunization.xsl file. The element client_id comes back null.
    <rowset xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0">
    <xsl:for-each select="/request/parameters/*">
    <row>
    <xsl:element name="client_id"><xsl:value-of select="//s_org_client_id"/></xsl:element>
    <xsl:element name="vaccine_group_code">
    <xsl:choose>
    <xsl:when test="item_no = 145">PNEU</xsl:when>
    <xsl:when test="item_no = 144">FLU</xsl:when>
    <xsl:otherwise></xsl:otherwise>
    </xsl:choose>
    </xsl:element>
    </row>
    </rowset>

    Hi J
    Have you added the <<Page()>> and <<PageCount()>> functions on the reports?
    FR does not (or certainly did not) add page numbers to the reports in books unless you manually add them. I always used to add a text box in the footer of the report and insert functions like this. It has been a while since I did it (I haven't on 11.1.2.1 for example) but I think that if you do this the page number corresponds to the page within the book and not the page of the report (if a multi-page report). It may not take account of a TOC page though.
    Hope this helps
    Stuart

  • Help: on using xsl:param

    I am working on some xsl codes to do transformation,
    I have some codes like this:
    <xsl:template match="mytemplate">
    <xsl:param name="myparam"><xsl:number value="count()"/></xsl:param>
    function myfunction_{$cid} ()
    <!--I want the function name shows as "function myfunction_5 ", (5 is return value of count()).-->
    </xsl:template>
    Any help is greatly appreciated!

    Why would you use <xsl:param> to do that? Try this instead:
    function myfunction_<xsl:number value="count()"/> ()
    Or if you saw an example of an attribute value template somewhere else and tried to use it without understanding it, how about this:
    <xsl:variable name="cid"><xsl:number value="count()"/></xsl:variable>
    function myfunction_{$cid} ()
    Finally, what does this have to do with Java? There are plenty of active XSL mail lists where you would be much more likely to get a useful answer.

  • XSQL to XSL params passing problem

    I'm trying to pass some parameters from XSQL to processing XSL, but I am unable to pass string constants. To make it clear:
    XSQL:
    <?xml version="1.0" ?>
    <?xml-stylesheet type="text/xsl" href="some.xsl" ?>
    <qry xmlns:xsql="urn:oracle-xsql" connection="orcl8">
    <xsql:set-stylesheet-param name="from" value="{@f}" />
    <xsql:set-stylesheet-param name="where" value="{@w}" />
    <xsql:set-stylesheet-param name="orderby" value="{@o}" />
    <xsql:query max-rows="{@mr}" skip-rows="{@sr}" null-indicator="yes">
    <![CDATA[
    select * from {@f} where {@w} order by {@o}
    ]]>
    </xsql:query>
    </qry>
    XSL (most of code omitted to save space):
    SELECT * FROM <xsl:value-of select="$from"/>
    WHERE <xsl:value-of select="$where"/>
    ORDER BY <xsl:value-of select="$orderby"/>
    If I pass w=FIELD='some string' (and even when I use &apos; ) all parameters passed to the XSL come empty. Everything without apostrophes comes in just fine, but appearance of apostrophes or their escaped equivalents causes all parameters to get in empty. Query is executed correctly though.
    Am I doing something wrong or there's a bug in XSQL processor (or maybe what I'm trying to do is simply impossible - I just started to learn XML/XSLT and not sure I'm getting everything right...)?
    regards,
    Bob.
    null

    In my xsql I run various SQL statements. Some of these select configuration type details for that user/session. So the returned XML includes business data and some configuration data.
    My main XSL uses these values to determine which templates to process. I use xsl:choose.
    It does mean a big choose statement but it works fine.
    Matt

  • XSL and a php variable

    I am looking for a solution to a problem I am having with an
    XSL stylesheet and trying to use a php variable. The page I am
    working on is a page to display some information based on the
    graduation year of a class (I work at a school). For example last
    years graduating class of 2006.
    I have a statement in the XSL sheet that limits the shown
    data to only that class year
    <xsl:for-each
    select="school[class_of=&apos;2006&apos;]">
    I would like to replace that 2006 above with a php statment
    such as $classyear since on that page the data is to display the
    variable is already present, but I cannot get it to work. I have
    tried to place php in the XSL and also to change the extention etc
    and they all produce errors. I am assuming that XSL just can't use
    variables in it?
    Any help would be greatly appreciated. I would hate to have
    to duplicate that one XSL sheet for every class year.
    thanks
    chris

    David,
    thank you so much so far for you help, it does sounds like we
    are talking about the same thing. I think I am getting close.
    I do want to pass the value when the XSL sheet is embedded.
    I tried that and it seemed to not work, says the variable is
    not found (I am using the dreamweaver built in transform).
    I am just getting into the more complex XML stuff so I
    apologize for my lack of knowledege.
    I have pasted some of the code below, any idea what I am
    doing wrong?
    the page where it is embedded is
    http://www.nmhschool.org/news/test11.php
    php doc with the embed and include
    <?php
    $mm_xsl = new MM_XSLTransform();
    $mm_xsl->setXML("test11.xml");
    $mm_xsl->setXSL("test11.xsl");
    $mm_xsl->addParameter("yearXX", "2006");
    echo $mm_xsl->Transform();
    ?>
    http://www.nmhschool.org/news/test11.xsl
    is the XSL
    <xsl:for-each
    select="Report/GroupHeader2/GroupHeader2_1[q1.CnPrAl_Class_of =
    $yearXX]">
    <table width="100%" border="1" cellspacing="1"
    cellpadding="1">
    <tr> blah blah blah........
    http://www.nmhschool.org/news/test11.xml
    is the XML data

  • Omniportlet XML : Param to XSL Filter

    Hi,
    I have an xml file not in the <rowset><row></row></rowset> format to display in an XML Omniportlet.
    I have made a XSL file to transform it.
    My portal is in three languages.
    I have added a param (<xsl:param name="lang">) to my XSL file.
    How can I pass the NLS_LANG to that XSL file ?
    I tryed to add a system parameter on the page to the omniportlet containing the NLS_LANGUAGE but it doesn't seems to work.
    I tryed to set the XSL URL to : url/file.xsl?lang=##Param1##
    How to do it ?
    Thank you for your help.
    Benoit Pironet
    Message was edited by:
    Benoit.Pironet

    Hello, I have a problem with the same omniPortlet. I have to show data from an xml file exported with excel and I can´t build the filter.xsl correctely... always I get some error.... like
    *"Target XML document does not conform to a rowset-row structure."* or
    *"Failed to load user defined filter"*
    Could anybody Help me??
    Could anybody send me an example, an xml file (exported with Excel) with its xsl file that works?? PLEASE???

  • Can we use xsl:param element in XSLT mapping...?

    Hi Guys
    Can we use <xsl:param> element in XSLT mapping in XI..?
    Is there any documentation out there for XSLT mapping?
    Thanking in advance

    Hi,
    Check this link for an example:
    https://www.sdn.sap.com/sdn/url.sdn?res=/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/uuid/6c514a4f-0501-0010-038c-994da5200215
    Regards,
    Sridhar

  • Generating URL params in XSL

    Hi
    I have what seems to be a very common problem, but cant find any answers.
    I want to build a URL based on whats in my XML, but am having trouble with escape chars etc etc. The output I want is:
    find.jsp?searchType=<xsl:value-of select="SearchType"/>&name=<xsl:value-of select="Name"/></xsl:attribute></td>
    I cannot get the values 'bob' or 'full' dynamically, or if I do, Xalan has trouble with the '<' characters. I have tried every possible combination and none seem to work quite right. Has anyone solved this problem?
    Thanks
    Richard

    Hey, thanks for the quick reply!!!
    I got it to work using another way too:
    <a>
    <xsl:attribute name="href">find.jsp?searchType=<xsl:value-of select="SearchType"/>&name=<xsl:value-of select="Name"/></xsl:attribute>
    </a>
    (I'm sure I tried the above before and it didnt work.... ;)
    I will bear both in mind next time I have this problem
    Cheers
    Rich

  • Xsl:param question

    hi in my xsl
    I have something that is like
    <xsl:param name="x" select="@somevalue"/>
    that @somevalue is suppose to have a value assigned to it (so it is dynamic).......but I can't figure out how it might work
    can someone provide my some info as to how @ this works in the xsl world....
    basically I want to know how i can assign value to that @somevalue...
    jaxb...?!
    thanks

    Are you asking what the @ character means? It's a shortcut for the attribute axis, so basically "@somevalue" means "the somevalue attribute of the context node".

  • XMLTansform and xsl:param values

    Hello,
    I would like to know if it is possible to pass xsl:param values when calling XMLTransform(xml, xsl).
    If not, is there another way to render an XML with an XSL that takes parameters?
    Thank you.

    RDC has been deprecated since version 9 meaning no new functionality has been added to it. Cascading Parameters were added in CR 11.
    There is no set of API's to access these types of Parameters at this time.

  • XSL param filter for character length?

    Hi I am using a xsl a transformation and using a param filter to only show 4 items (Works great!) but I would only like to show the first 50 Characters of the Article... is there a param filter I could pass to do this? or Would I need to make a new XML node to show?
    Thanks for any help!
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" encoding="UTF-8"/>
    <xsl:param name="ItemsPerPage" select="4" />
    <xsl:template match="/">
    <xsl:for-each select="dataroot/item[position() &lt;= $ItemsPerPage]">
    <xsl:sort select="date" order="descending"/>
      <h3><xsl:value-of select="title" disable-output-escaping="yes"/>
        </h3>
       <h5><xsl:value-of select="location"/> :
      <xsl:value-of select="date"/></h5>
       <h5><xsl:value-of select="author"/></h5>
        <xsl:value-of select="article" disable-output-escaping="yes"/>
          <xsl:value-of select="image"/>
           <xsl:value-of select="link"/>
    <br class="clearfloat" />
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    IsleA-Row2_Seat7

    Try this:
    <xsl:value-of select="substring(article, 1, 50)" disable-output-escaping="yes"/>
    AFAIK, that will cut it off at 50 characters. An alternative that might be more elegant is to select the first sentence and add an ellipsis like this:
    <xsl:value-of select="substring-before(article, '. ')" disable-output-escaping="yes"/>
    <xsl:text>... </xsl:text>

  • Xsl:param

    I run XSL-script from Java-servlet using XML parser v.2.0.2.9.
    I want to pass the node list to stylesheet script. How can i do it?? For example:
    XML -------------
    <root>
    <leaf>1</leaf>
    </root>
    XSL -------------
    <xsl:param name='new_leaves'/>
    <xsl:template match='leaf'>
    <xsl:copy-of select="$new_leaves"/>
    </xsl:template>
    When servlet runs XSL-script it passes parameter by setParam(...).
    The result XML-file must be something like:
    Result XML ------
    <root>
    <leaf>2</leaf>
    <leaf>3</leaf>
    </root>
    When parameter is literal value then all right. The problem rises when i want to pass the node list for a parameter.
    Thanks

    Cannot be done directly to the best of my knowledge.
    You could pass a value which is a space-separated list of numbers, then write an XSLT recursive template to parse the space-separated list of numbers and turn it into the XML fragment you're trying to create.

  • Xsl:import and xsl:call-template errors for xslt in mediator (ORAMED-03601)

    Hello,
    I decided for performance issues with bpel execution to use a mediator instead.
    In my requester i have a mediator that justs recieves an xml message, uses an xsl transformation (version 2) on that message and then sends it to the EBS.
    The xsl file that's works correctly when used in a bpel process has both <xsl:import..../>and <xsl:call_template.../> tags.
    When i tried and used the same xsl in the mediator i get an ORAMED-03601 error:
    ORAMED-03601:[Invalid transformer configuration]Unable to create transformer. It could be because of transformation file or configuration issues. Reason : "xsl/Xform_PriceListListABMReqMsg_to_PriceListEBMReqMsg.xsl"Possible Fix:Check log file for any exceptions and contact Oracle Support Services for further help
    It works correctly again if i comment/remove all the imports and call-template and incorporate them in the xsl file itself.
    Do anyone know if there are some limitations using xsl in a mediator instead of a bpel?

    Hi,
    I have a problem with call-template. I have passed
    sed some parameter with call-template tag and used
    that parameter in the conditional check tag <xsl:if>
    i am getting the error. Can any body tell how to use
    this? I actuall want to dynamically pass the tag name
    as the parameter and check the attribute value of the
    tag passed in the if condition and then i want to
    person some action. How can i do it?
    Here is the call-template code:
    <xsl:call-template name="selected-unselected">
    <xsl:with-param
    ram name="currentTag">motor-carrier</xsl:with-param>
    </xsl:call-template>
    Here is the template definition:
    <xsl:template name="selected-unselected">
    <xsl:param
    m name="currentTag">Quick-Quote</xsl:param>
         <xsl:if test="./{$currentTag}/@selected='true'">
              <xsl:text>checked</xsl:text>
         </xsl:if>
         <xsl:if test="./{$currentTag}/@selected='false'">
              <xsl:text>Unchecked</xsl:text>
         </xsl:if>
    </xsl:template>
    Here is the sample xml code:
    <motor-carrier selected="true"/>
    <motor-truck selected="false"/>
    <sched-mobile-equip selected="false"/>
    Here instead of writing the condition check for every
    tag i want to write it once and dynamically pass the
    tag name as parameter to the template. If the
    attribute of the tag has value true then one message
    should be displayed otherwise a different message
    should be displayed.try this:
    <xsl:template name="selected-unselected">
         <xsl:paramm name="currentTag">Quick-Quote</xsl:param>
         <xsl:if test="./*[name()=$currentTag]/@selected='true'">
              <xsl:text>checked</xsl:text>
         </xsl:if>
         <xsl:if test="./*[name()=$currentTag]/@selected='false'">
              <xsl:text>Unchecked</xsl:text>
         </xsl:if>
    </xsl:template>

  • Xsl question - call xsl from another xsl

    Hi,
    I have a xsl which should be invoked from another xsl. I have a transformheader.xsl which transforms the header values. I would like to invoke this xsl from various client xsl files.(to transform the header).
    transformheader.xsl should take the header as input and give header as output.
    Basically I am moving the header transform logic to one xsl file & reuse it.
    Can you please help me with the syntax or any links to samples/docs?
    transformheader.xsl:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsl:stylesheet version="1.0">
    <xsl:template match="/">
    <ns1:header>
    <ns1:ebmAID>
    <xsl:value-of select="/ns1:header/ns1:ebmBID"/>
    </ns1:ebmAID>
    <ns1:ebmBID>
    <xsl:value-of select="/ns1:header/ns1:ebmAID"/>
    </ns1:ebmBID>
    </ns1:header>
    </xsl:template>
    </xsl:stylesheet>
    client1.xsl(transforms one message to other, both has the header)
    <?xml version="1.0" encoding="UTF-8" ?>
    <?oracle-xsl-mapper......>
    <xsl:stylesheet version="1.0">
    <xsl:template match="/">
    <tns:sampleee>
    <hdr:header>
    ===== invoke the transformheader.xsl to insert the header here
    </hdr:header>
    <tns:body>
    <xsl:for-each select="xxxxx">
    </tns:body>
    </tns:sampleee>
    </xsl:template>
    </xsl:stylesheet>

    Here you go:
    CreateHeader.xsl
    <xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:inp="http://temp.org/input"
            xmlns:out="http://temp.org/output"       
                    >
         <xsl:template name="CreateHeader">
                 <xsl:param name="InputHeader"/>
                   <out:header>
                        <out:ebmAID>
                             <xsl:value-of select="/inp:header/inp:ebmID"/>
                        </out:ebmAID>
                        <out:ebmBID>
                             <xsl:value-of select="/inp:header/inp:ebmContextID"/>
                        </out:ebmBID>
                   </out:header>
         </xsl:template>
    </xsl:stylesheet>Main XSL:
    <xsl:stylesheet version="1.0"
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
         xmlns:inp="http://temp.org/input"
            xmlns:out="http://temp.org/output"       
                    >
         <!-- Import the createHeader.xsl here -->
         <xsl:import href="CreateHeader.xsl"/>
         <xsl:template match="/">
              <out:RootElement>
                   <!-- This will inser the header by calling the CreateHeader XSL -->
                   <xsl:call-template name="CreateHeader">
                        <xsl:with-param name="InputHeader" select="inp:header"/>
                   </xsl:call-template>
                   <xsl:for-each select="/inp:body">
                        <out:body>
                             <!-- logic for creating body goes here -->
                        </out:body>
                   </xsl:for-each>
              </out:RootElement>
         </xsl:template>
    </xsl:stylesheet>

Maybe you are looking for

  • Very odd internet issues.

    I just bought a 21.5" refurbed iMac. Worked great for a week and now for the past week or so, I cannot stay connected to either Firefox or Safari for more than 2 minutes before the browser starts "Looking up" the website and then it completely discon

  • STO Outbound delivery issue

    Hi All, I've a intercompany customer (say ICABCD) which has Ship-to Party maintained as 12345678 (not same as Sold-to Party) in Customer master. Now when I create a I/C PO to procure goods for ICABCD and create delivery (outbound), it sets Ship-to Pa

  • My icloud won't let me verify the account!! there is no mails sent to my mailbox/trash or any other filter. is there a fix??

    I have ipone/ipad/apple tv/macbook pro and a imac but none of them will sync with the cloud!!

  • I need date mapping Below based on condition?

    Source sidefield:ZALDAT Taget Structure mapping condition: Format MMDDYY. If check is voided then it should be '000000' Taget field:Issue date I Need how to mapping source to target field based on conditioin explain me?give me saple mapping given con

  • Eric Clapton Album Won't Sync "You are not Authorized"

    Hi, I need some help. I just got my new mac mini, and im very happy with it. However, all my music, except my Eric Clapton album is syncing. It's giving me messages like, "The following items including "ride the river" were not synced to <ipod name>