Count no of elements in XMLAGG

Given this:
SELECT XMLELEMENT("Department",
      XMLAGG(XMLELEMENT("Employee", e.job_id||' '||e.last_name)))
   AS "Dept_list"
   FROM employees e
   GROUP BY e.department_id;How do I get the number of rows/elements for each department in as an attribute in the Department tag?
And in this one:
SELECT XMLELEMENT("Department",
   XMLAGG(XMLELEMENT("Employee",
   e.job_id||' '||e.last_name)
   ORDER BY last_name))
   as "Dept_list"    
   FROM employees e
;The real live example sql is rather big and contained in a WITH stament (where I can make the analytics count(*) within group .... but it says error when ran together with the XML stuff
ANy ideas?
Mette

How do I get the number of rows/elements for each department in as an attribute in the Department tag?With XMLAttributes :
SELECT XMLElement("Department",
         XMLAttributes(count(*) as "nb_emp"),
         XMLAgg(
           XMLElement("Employee", e.job_id||' '||e.last_name)
       ) AS "Dept_list"
FROM hr.employees e
GROUP BY e.department_id
And in this one:Not sure what you want for the 2nd query...
Something like this?
WITH emp_list AS (
  SELECT e.job_id,
         e.last_name,
         count(*) over(partition by e.department_id) as nb_per_dept
  FROM hr.employees e
SELECT XMLElement("Department",
         XMLAgg(
           XMLElement("Employee",
             XMLAttributes(nb_per_dept as "nb_per_dept"),
             job_id||' '||last_name
           ORDER BY last_name
       ) AS "Dept_list"    
FROM emp_list
;

Similar Messages

  • Different file count between Photo Elements 12 and Lightroom 5.

    To Whom it might concern:
    When I check properties the file count in Photo Elements 12 is different than that of Lightroom 5.
    In one case Photo Elements shows 743 files and 51 folders and lightroom shows 734 files.
    I counted each a every file and found Lightroom to have the correct count and Elements the same count
    but properties shows a count of 743.
    Please answer.
    Albert F Schwartz Jr
    E-mail - [email protected]

    If you think you have found a bug, you should report it to Adobe here: http://feedback.photoshop.com/
    This forum is not the place for bug reports

  • How to get the count of repeating elements in a xml doc.

    In many xml documents, in is common to have repeating child elements and what I would like to know is how do I determine exactly how many of these child elements exist in a particular document. There is probably a correct XPath string to determine this, but I cannot figure out what it is. Here is an example
    <a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>
    The above 'c' element is what varies in number from document to document and I need to know how to get the number of 'c' elements for the document, which would be 3 in the above case.

    create table test_xml(data xmltype)
    insert into test_xml values(
    xmltype('<a>
    <b>
    <c>1</c>
    <c>5</c>
    <c>22</c>
    </b>
    </a>')
    select extract(data, '/a/b/c').getclobval() from test_xml
    select count(*) from test_xml
    where existsnode(data, '/a/b/c')=1
    good luck.

  • Select count(*) and blank element tags

    Is there a way other than column aliases to produce and return an element tag for the following xsql query.
    <xsql:query
    connection="{@cxn}"
    xmlns:xsql="urn:oracle-xsql">
    select count(*) from emp
    </xsql:query>
    Some databases such as SQL Server via a JDBC driver will return a blank column name, thus you'll have an invalid XML document, however SQL Server allows one to use column aliases, such as select count(*) as "count" from emp.
    However some databases such as Progress via a JDBC-ODBC bridge and ODBC driver does NOT allow column aliases. Thus I'll always get the following response:
    <ERROR>oracle.xml.sql.OracleXMLSQLException: String index out of range: </ERROR>
    Question. Can I substitute an element tag when I encounter a blank column name using an action handler? Any ideas? Sample code?
    Steve.

    Please have the data structure as below:
    <datastructure>
    <GROUP name="G_1" source="Q_TEMP">
    <element value="DEPTNO" name="DEPTNO" />
    <element value="DNAME" name="DNAME" />
    <element value="LOC" name="LOC" />
    <GROUP name="G_2" source="Q_TEMP1">
    <element value="ENAME" name="ENAME" />
    <element value="SAL" name="SAL" />
    *</GROUP>*
    *<element value="G_2.ENAME" name="TOTL_DETAILS" dataType="number" function="COUNT()" />*
    *<element value="G_2.SAL" name="TOTL_SAL" function="SUM()"/>*
    *</GROUP>*
    </datastructure>
    Aggregate functions to be placed at the level you require it. Here you need at G_1, so place it there.

  • Counting number of elements in an array which aren't empty?

    i tried using this method to count an array which has 100 elements but it doesn't go past the while statement which i cant figure out?
    public static void countCust()
    int cntr = 0;
    int z;
    for (int c = 0; c < 100; c++)
    while (customer[c].indexOf(':') != -1)
    cntr++;
    javax.swing.JOptionPane.showMessageDialog(null, "There are " + cntr + " customers on record");
    }

    Are you getting NullPointerExceptions?
    Are you sure customer[] has been allocated?
    Are you sure each element in the array is non-null?
    BTW, it's traditional to use variables in loops that are closer to their mathematical usage. I mean, for an array index, usually you'd use variables named i or j, unless the indices map to coordinates in space, in which case you'd use x, y, and z.
    If neither of these is applicable, use a variable with a more meaningful name.

  • Counting number of elements

    Suppose you have xml that has repeated nodes, like:
    <foo>
    <bar>some</bar>
    <bar>stuff</bar>
    <bar>here</bar>
    </foo>
    What query would I give to count the number of <bar> elements? Also, is there a query that would concatenate the contents of all of them?
    Thanks.

    This is covered in the standard XDB Demo
    select count(*)
    from purchaseorder,
    table (xmlsequence(extract(object_value,'/PurchaseOrder/LineItems/LineItem'))) l

  • Count number of elements

    Dear All,
    probably there is somethin wrong in how I use the xmlsequence...
    I have a table called XML_WORD with a fiels with XML Docs called XML_CONTENT
    As you see what I want to try is to count the number of elements into a certain node...
    What is wrong in the statement I wrote?
    Thanks a lot and hope this will solve my problem with XML_SEQUENCE.
    Stefano
    SQL> desc XML_WORD
    Name Null? Type
    ID NUMBER
    WORD_ID CHAR(40)
    LEMMA CHAR(60)
    XML_CONTENT SYS.XMLTYPE(XMLSchema "http:
    //word.xsd" Element "word")
    STORAGE Object-relational TY
    PE "word5828_T"
    IS_ACTIVE NUMBER
    RELEASE_CODE NUMBER
    SQL> edit
    Wrote file afiedt.buf
    1 select count(*)
    2 from XML_WORD,
    3 table (xmlsequence(extract(XML_CONTENT,'count(/word/noun/sense[1]/collocation')))
    4* where ID=9973
    SQL> /
    from XML_WORD,
    ERROR at line 2:
    ORA-31013: Invalid XPATH expression

    Sure - thanks for the time and thoughts.
    I am using the schema you helped me with a bit ago, Re: unique constraint defined in xsd
    I have tried to create a stored function that will return the number of maps per username and also one that will return the map elements based on a passed username.
    CREATE OR REPLACE FUNCTION COUNTMAPS(userName varchar2)
    return number
    as numMaps number;
    begin
    select count(*)
    into numMaps
    from mapsetxml,
    table (xmlsequence(extract(object_value,'/mapset/map')))
    where existsNode(object_value, '/mapset[" ' ||userName|| ' "]')=1;
    return numMaps;
    end;
    I get the total number of maps, not the number of maps associated with a particular user.

  • Count the number of elements in comma seperated list of values

    Hello Friends,
    I have a string with comma seperated list of values say
    String v = 34343,erere,ererere,sdfsdfsdfs,4454,5454,dsfsdfsfsd,fsdfsdfsdfs,dfdsfsdfsdfs,sdsfdsf,ererdsdsd45454,fsdfsdfs
    Want to count how many elements are existing in this string .
    Thanks/Kumar

    Hi, Kumar,
    REGEXP_COUNT, which Hoek used, is handy, but it only works in Oracle 11. Which version of Oracle are you using?
    In any version of Oracle, you can count the commas by seeing how much the string shrinks when you remove them.
    LENGTH (str) + 1 - LENGTH (REPLACE (str, ',')) Can str have multiple commas in a row? What if there's nothing between consecutive commas, or nothing by whitespace? Can str begin or end with a comma? Can str consist of nothing but commas? Depending on your answers, you may have to change things. You might want
    REGEXP_COUNT ( str
                 , '[^,]+'
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.
    See the forum FAQ {message:id=9360002}

  • Xslt/xpath: count preceding elements which starts-with 'S'

    Hi everybody,
    I got the following XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
         <A1>
              <FOO>1</FOO>
         </A1>
         <A1>
              <FOO>2</FOO>
         </A1>
         <B1>
              <FOO>3</FOO>
         </B1>
         <A1>
              <FOO>4</FOO>
         </A1>
    </ROOT>
    I want wo count all preceding Elements of each 3
    How has the experssion has to look?
    count(/ROOT/A1/FOO/preceding::[starts-with(.,'A')])
    DOES not work
    Any suggestions?
    Regards Mario
    Edited by: Mario Müller on Sep 12, 2008 2:23 AM

    Hi Mario,
    What are you using to test xsl expressions?
    I am using XSL Tester, all sugestions that i gave you retrieve a solution. Therefore, this solution will depend from XML tree. For instance if you have something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <ROOT>
         <A1>
              <FOO>1</FOO>
              <FOO>5</FOO>
                            <A1000>
                                  <FOO>46</FOO>
                           <FOO>400</FOO>
                            </A1000>
              <FOO>300</FOO>
         </A1>
         <A2>
              <FOO>2</FOO>
              <FO>6</FO>
         </A2>
         <B1>
              <FOO>3</FOO>
         </B1>
         <A1>
              <FOO>4</FOO>
              <FO>7</FO>
         </A1>
    </ROOT>
    Using this XSL:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
                <Result>
                   ---- Expression ----
              </Result>
         </xsl:template>
    </xsl:stylesheet>
    Results using the expressions that i gave you, will be:
    1.1
    <xsl:value-of select="count(//FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
         <Result>7</Result>
    1.2
    <xsl:value-of select="count(//FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
        <Result>4</Result>
    2.1
    <xsl:value-of select="count(/ROOT/*/FOO[starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
      <Result>5</Result>
    2.2
    <xsl:value-of select="count(/ROOT/*/FOO[1][starts-with(name(parent::node()),'A')])"/>
    <?xml version="1.0" encoding="UTF-16"?>
        <Result>3</Result>
    I think the last one, fits your solution. Give me more hints, maybe i can help you.
    Best regards,
    Pedro Pereira

  • XMLAGG problem

    We have stored procedure which creates a long string of XML (which is stored as a clob in the database column)using the xmlAGG and XMLElement. The stored proc calls sub functions which all run fine when called individually however when called collectively from the stored proc the xml generated appears corrupted with a section missing and always gets corrupted at the same point i.e. a sub function pulls back a number of installment records - when we try to retrieve more than 4 records 1016 bytes the result gets corrupted. We are using oracle 10g with the latest patches 10.0.2.0.2 and running it on a linux - we also tried it from a windows platform but get the same problem. We know its not the code that is the problem because it works fine from a linux machine. Has anyone else experience similar problems or have any ideas on how to resolve?

    Sorry yes noticed the typo in my original post. It occurs on both linux and windows but not apparently AIX. the data is accumulated into a big XML ELEMENT using XMLAGG and XMLELEMENT and XMLTYPE. when all data required has been accumulated a toClob is performed which is the format it is stored in database as. Originally we used a 9i database on windows and had no problems at all with the exact same code but customer wishes to upgrade to 10g which we have had problems with but they have not had problems with 10g installed in AIX box.
    Here is the stored procedure :
    PROCEDURE LTR_CUSTOMER_STATEMENT_SP
    /*======================================================================
    ** Inputs
    **=====================================================================*/
    IN_PAYMENT_PLAN_ID IN VARCHAR2, -- Identifies the Payment Plan
    IN_FROM_DATE IN VARCHAR2, -- Lower bound for installments,
    -- payments and broker fees
    IN_UNTIL_DATE IN VARCHAR2, -- Upper bound for installments and payments
    /*=======================================================================
    ** Input / Outputs
    **=====================================================================*/
    RESULT_SET_LIST IN OUT KPK_PPP_DATATYPES.letter_data_result_list,
    -- returnedXML in result set
    SUCCESS OUT NUMBER -- Success value
    AS
    /*=======================================================================
    ** Local vars
    **=====================================================================*/
    pay_plan_id_p INTEGER; -- Holds CRN converted
    from_date_p DATE; -- Holds from date converted
    until_date_p DATE; -- Holds until date converted
    li_agency_id_p INTEGER; -- holds the agency id of the latest loan on the payment plan
    BEGIN
    /*=======================================================================
    ** Assign local vars
    **=====================================================================*/
    pay_plan_id_p := TO_NUMBER(IN_PAYMENT_PLAN_ID);
    from_date_p := TO_DATE(IN_FROM_DATE, 'DD/MM/YYYY');
    until_date_p := TO_DATE(IN_UNTIL_DATE, 'DD/MM/YYYY');
    /*=======================================================================
    ** Get agency id
    **=====================================================================*/
    SELECT agency_id INTO li_agency_id_p
         FROM (SELECT agency_id
         FROM LOAN l
         WHERE l.payment_plan_id = IN_PAYMENT_PLAN_ID
         ORDER BY l.created_on DESC)
         WHERE ROWNUM = 1;
    BEGIN
    OPEN RESULT_SET_LIST FOR
    SELECT XMLElement( "LETTER",
    /*==============================================================
    ** Add the 'ALL_LETTERS' node
    **==============================================================*/
    ( SELECT XML_RETURN_BLOCK FROM LTR_SUB_ALL_LETTER_INFO_V
    WHERE PAYMENT_PLAN_ID = pay_pln.ID),
    /*======================================================
    ** Add the 'HIB_COMPANY_INFO' node
    **=====================================================*/
    ( SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_HIB_COMPANY_INFO_V
    WHERE AGENCY_ID = li_agency_id_p),
    /*=========================================================
    ** Add the 'CONTACT INFORMATION' node
    **========================================================*/
    XMLElement ( "CONTACT_INFORMATION",
    ( SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_CUST_CONTACT_INFO_V
    WHERE PAYMENT_PLAN_ID = pay_pln.ID),
    ( SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_HIB_CONTACT_INFO_V
    WHERE AGENCY_ID = li_agency_id_p),
    ( SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_BROKER_CONTACT_INFO_V
    WHERE PAYMENT_PLAN_ID = pay_pln.ID)
    ), -- End XMLElement
    /*==============================================
    ** Add the 'PLAN DETAILS' node
    **=============================================*/
    LTR_SUB_PLAN_INFO_SP
    (pay_pln.ID, from_date_p, until_date_p, 'N'),
    /*===============================================
    ** Add the 'POLICY DETAILS' node
    **==============================================*/
    LTR_SUB_POLICY_INFO_SP
    (pay_pln.ID, from_date_p, until_date_p, 'N'),
    /*===============================================
    ** Add the 'BANK DETAILS' node
    **==============================================*/
    (SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_BANK_DETAILS_V
    WHERE PAYMENT_PLAN_ID = pay_pln.ID),
    /*===============================================
    ** Add the 'Originator identificatin number' node
    **==============================================*/
    ( SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_ORIGINATOR_NUMBER_V),
    /*===============================================
    ** Add the 'Refund Originator number' node
    **==============================================*/
    ( SELECT XML_RETURN_BLOCK
    FROM LTR_SUB_REFUND_ORIG_NUM_V),
    /*===============================================
    ** Add the ''BROKER FEES' node
    **==============================================*/
    LTR_SUB_BROKER_FEES_SP (pay_pln.ID, from_date_p)
    ).getClobVal() -- End Main XMLElement (return as CLOB)
    FROM PAYMENT_PLAN pay_pln
    WHERE pay_pln.ID = pay_plan_id_p;
    /*=======================================================================
    ** Handle any exceptions
    **=====================================================================*/
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    SUCCESS := -1;
    RETURN;
    WHEN OTHERS THEN
    SUCCESS := SQLCODE;
    RETURN;
    END;
    /*==========================================================================
    ** Set the success value
    **========================================================================*/
    SUCCESS := 0;
    END;
    This is the sub function which works when called on its own but not cumulatively with everything else:
    CREATE OR REPLACE FUNCTION LTR_SUB_PLAN_INFO_SP
    IN_PAYMENT_PLAN_ID in INTEGER, -- Payment Plan identifier
    IN_FROM_DATE in DATE, -- Lower date range for payment date
    IN_UNTIL_DATE in DATE, -- Upper date range for payment date
    IN_EXCLUDE_PAID_PAYMENTS in CHAR -- Exclude payments that have already been paid?
    RETURN XMLType IS XML_RETURN_BLOCK XMLType;
    BEGIN
    /*==============================================================================
    ** Get the payment plan for the supplied ID
    **=============================================================================*/
    SELECT XMLElement( "PLAN_INFORMATION",
    XMLForest ( plan.CUSTOMER_ID AS CRN,
    plan.OVERPAYMENT AS OVERPAYMENT_AMT,
                                            KPG_UTILS.NUM_LOANS_BEFORE_MIGRATION(IN_PAYMENT_PLAN_ID) AS NUM_LOANS_B4_MIGRATION
                                            SELECT COUNT(*)
                                            FROM PLAN_INSTAL_CURRENT_ACTIVE_V pinst
                                            WHERE pinst.PAYMENT_PLAN_ID = plan.ID
                                                 AND pinst.DUE_DATE >= IN_FROM_DATE
                                                 AND pinst.DUE_DATE <= IN_UNTIL_DATE
                                            AND pinst.CODE_TYPE = 'INSTSTATUS'
                                                 AND (IN_EXCLUDE_PAID_PAYMENTS = 'N' OR pinst.STATUS_CODE NOT IN ( 'PD', 'SE', 'CP', 'CA', 'WO' )))
                                            AS NUMBER_PLAN_INSTALMENTS,
              ( SELECT TO_CHAR(
                                                 ROUND(NVL(SUM(pinst.BROKER_FEE),0),2)      , '9999990.90')
                                            FROM PLAN_INSTAL_CURRENT_ACTIVE_V pinst
                                            WHERE pinst.PAYMENT_PLAN_ID = plan.ID
                                                 AND pinst.DUE_DATE >= IN_FROM_DATE
                                                 AND pinst.DUE_DATE <= IN_UNTIL_DATE
                                            AND pinst.CODE_TYPE = 'INSTSTATUS'
                                                 AND pinst.STATUS_CODE NOT IN ( 'PD', 'SE', 'CP', 'CA', 'WO' )
                                                                ) AS TOTAL_UNPAID_BROKER_FEE
                                            ), --XMLForest
    XMLElement ( "INSTALMENTS",
    /*==============================================================================
    ** Get the installments for this payment plan. Select those between the
    ** the dates specified and excluding paid payments if required. Also, select
    ** the correct REF_CODE so the description of the status of the payment can be
    ** added to the output
    **=============================================================================*/
    ( SELECT XMLAGG ( XMLElement ( "INSTALMENT_ROW",
    XMLAttributes(LTRIM(TO_CHAR(pinst.DUE_DATE,'ddth fmMonth YYYY'), '0') AS DUE_DATE,
         TRIM(TO_CHAR(ROUND( (pinst.GROSS + pinst.BROKER_FEE) , 2), '9999990.90')) AS AMOUNT,
                                                                                              TRIM(TO_CHAR(ROUND( (pinst.BROKER_FEE) , 2), '9999990.90')) AS BROKER_FEE,
    pinst.DESCR AS STATUS,
                                                                                                        pinst.STATUS_CODE AS STATUS_CODE,
                                                                                                        LTRIM(TO_CHAR(pinst.ACTUAL_DATE,'ddth fmMonth YYYY'), '0') AS SINGLE_POLICY_COLLECTION_DATE
    ) -- End XMLElement
    ) -- END XMLAGG
                                                 FROM PLAN_INSTAL_CURRENT_ACTIVE_V pinst
                                            WHERE pinst.PAYMENT_PLAN_ID = plan.ID
                                                 AND pinst.DUE_DATE >= IN_FROM_DATE
                                                 AND pinst.DUE_DATE <= IN_UNTIL_DATE
                                            AND pinst.CODE_TYPE = 'INSTSTATUS'
                                                 AND (IN_EXCLUDE_PAID_PAYMENTS = 'N' OR pinst.STATUS_CODE NOT IN ( 'PD', 'SE', 'CP', 'CA', 'WO' ))
    ) -- End SELECT
    ) -- End XMLElement
    ) -- End XMLElement
    INTO XML_RETURN_BLOCK
    FROM PAYMENT_PLAN plan
    WHERE plan.ID = IN_PAYMENT_PLAN_ID;
    RETURN XML_RETURN_BLOCK;
    END;
    when more than 4 installment_rows are retrieved; the XML gets corrupted with a weird character appearing in the middle of the 5th row - although the code continues and brings back the results from the LTR_SUB_POLICY_INFO_SP

  • Need a relative sequence (count of record) in an input file in ESB input fi

    I am using ESB to pick up text files and pass them to a stored procedure. I have multiple variable length records in the file. I pass each record to the
    output file adapter, along with the input filename. I would also like to get a relative record number for each record within the file. I use an xsd file
    to convert the input to XML. The entire file is at the root level, each record is an element. Is there a way to get a relative count of each element?
    Here is the xsd file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    targetNamespace="http://TargetNamespace.com/Filein"
    xmlns:tns="http://TargetNamespace.com/Filein"
    elementFormDefault="qualified"
    attributeFormDefault="unqualified" nxsd:encoding="ASCII" nxsd:stream="chars" nxsd:version="NXSD">
    <xsd:element name="Root-Element">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="C1" type="xsd:string" nxsd:style="terminated" nxsd:terminatedBy="${eol}" nxsd:quotedBy="&quot;">
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    <!--NXSDWIZ:J:\\UPLD5383.INM:-->
    <!--USE-HEADER:false:-->
    I need to map the relative record number to a field in the output.
    Is there a function similar to the get filename that would return this value to me?
    <xsl:value-of select='ehdr:getRequestHeader("/fhdr:InboundFileHeaderType/fhdr:fileName","fhdr=http://xmlns.oracle.com/pcbpel/adapter/file/;")'/>
    I use this in the xsl file to get the file name .

    does each record start with a new line? if it does a
    simple wc -l can help you. If not, you can pre
    process this XML file by first removing all the new
    line characters using sed and then adding new line
    characters after the end tag of the xml using sed and
    finally doing a wc -l . this would be a simple shell
    script. Not sure if you want to use Unix shell
    scripting to achieve this.The sheer nature of XML means that it does not conform to any visual formatting. i.e. An xml file containing...
    <employee><empno>3</empno></employee>
    is identical in XML terms to...
    <employee>
    <empno>3</empno>
    </employee>
    which is also identical in XML terms to...
    <employee>
    <empno>
    3
    </empno>
    </employee>
    which is also identical in XML terms to...
    <employee><empno>
    3
    </empno></employee>
    etc.
    You cannot rely on the number of CR's or CR/LF's in the file to count the records. Proper XML processing should be used for such a task.

  • Counter in XSLT processing

    Is there anyway to keep an incremental counter in an XSLT stylesheet? I would like to append this counter to several element names to maintain uniqueness.
    Thanks
    Kathy

    I can generated the number I want using xsl:number. However, I don't know how to include it as part of the element name I am trying to generate.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    For example:
    <xsl:template match="DownlinkCellID_member">
    <xsl:number level="single" count="DownlinkCellID_member"/>
    <xsl:element name="DownlinkCellID{@index}">
    <xsl:value-of select="@value"/>
    </xsl:element >
    </xsl:template>
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    "index" is an attribute I included in the original XML file that I read and append to the element name. I would like to remove "index" from the original XML file and replace it's using in the xslt template with the output from xsl:number. How can I do this? Will it work if I create a variable?
    Thanks :-)

  • How to search for a particular element within a XML variable using studio?

    All,
    I am using studio 7.0 to develop a webbased application. In this, i need to access
    an oracle db using a WLAI Application View from my Workflow. I get some data back
    from Oracle as an XML variable and then apply an XPath statement to access the
    individual columns returned.
    My problem arises when there are no records in the db matching my criteria and
    an empty XML variable is returned to me from the app view. In these cases my
    XPath statement fails in studio causing an improper exit.
    Does anybody know how to check for content in a XML varaible using studio? So
    that if there is content i can proceed with XPath and if there is no content,
    then i will take a different route.
    Thanks in advance
    Regards
    Sri

    If I remember correctly, the adapter will return an XML document that contains
    XML elements for each row. You can just simply check the count of these elements
    with an XPath statement: ie. count(response/row)
    "Sri " <[email protected]> wrote:
    >
    All,
    I am using studio 7.0 to develop a webbased application. In this, i need
    to access
    an oracle db using a WLAI Application View from my Workflow. I get some
    data back
    from Oracle as an XML variable and then apply an XPath statement to access
    the
    individual columns returned.
    My problem arises when there are no records in the db matching my criteria
    and
    an empty XML variable is returned to me from the app view. In these
    cases my
    XPath statement fails in studio causing an improper exit.
    Does anybody know how to check for content in a XML varaible using studio?
    So
    that if there is content i can proceed with XPath and if there is no
    content,
    then i will take a different route.
    Thanks in advance
    Regards
    Sri

  • Counting number of lines in a text/csv file using xquery/xslt.

    Hi,
    I have a CSV file, I need to count the total number of lines in that file. This I have to use in OSB. My requirement is I have to count total no of lines in the $body file (CSV/flat file) and subtract header and footer lines from it.
    EX:
    header,1, @total_no_of_detal@
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    If suppose i have 10 detail lines, and I am getting body of the file as shown above,
    then in the final file, I have to change the body of the file as:
    header,1, *10*
    detail,1
    detail,2
    detail,3
    detail,n
    footer, 1
    Please advice how to do this in OSB.
    Edited by: user12679330 on Aug 2, 2011 2:34 AM

    I would suggest you to use MFL to convert the file into XML when you read it and then you can count the detail elements within the XML and update the values in Header element before writing the file again in flat file format again using MFL.
    You can read the documentation of Format Builder utility which is used to define MFL here:
    http://download.oracle.com/docs/cd/E21764_01/doc.1111/e15866/part_fb.htm
    Alternatively, another approach is the read the whole flat file as a text string and then doing needed manipulations to get what you need. If you want to do it like this then you will need to consider following things:
    1. Is the file in DOS format or Unix format? (To know the End of line character in use)
    2. Does the file contain an end of line at the end of file? (whether there is an end of line char at the end of data of footer record)
    Once you know above, you can try an xquery like following:
    let $intermediateXML :=
    <Root>
    for $a in (tokenize($in, 'EOL'))
    return
    if (string-length($a) > 0)
    then
    <record>{$a}</record>
    else ()
    </Root>
    let $count := count($intermediateXML/record)
    let $outXML :=
    <OutRoot>
    for $i in 1 to $count
    return
    if (data($i) = 1)
    then
    <Record>{concat($out, $intermediateXML/record[$i]/text(), ',Count=',($count)-2)}</Record>
    else
    <Record>{concat($out, $intermediateXML/record[$i]/text())}</Record>
    </OutRoot>
    return op:concatenate($outXML/Record/text(), 'EOL')In Above XQuery, replace EOL with the end of line character which for unix wound be "&#xA ;" (remove quotes and space between the A and ; ) and for DOS would be "&#xD ;&#xA ;" (remove quotes and space between the A and ; and D ; )

  • Need to set the Vissible row count Dynamically

    Hi,
       I have requirement where i am supposed to set the Vissible row count for a table dynmaically, depending upon the number of rows in a table.

    Or use a calculated attribute.
    Create an attribute in the context called calcVisibleRowCount of type integer and make it read only and calculated. Then bind that attribute to the visibleRowCount attribute of your table.
    The method for the attribute looks something like this:
    (this displays 10 rows per page if more than 10 records in the node, otherwise it displays the same number of rows in the table as in the context)
      public int getCalcVisibleRowCount(IPrivateStartsida.ILayoutElement element)
        //@@begin getCalcVisibleRowCount(IPrivateStartsida.ILayoutElement)
              if (wdContext.nodeXXXX().size() > 10) {
                   return 10;
              } else {
                   return wdContext.nodeXXXX().size();
        //@@end
    Note that this attribute is not created in the node that you want to count number of elements in.
    Edited by: Richard Linnander on Apr 1, 2011 3:41 PM

Maybe you are looking for

  • Missing parts for Process orders

    Hi Experts, We are trying to find out the Transaction to faciltate the Missing parts list for the process order even after the order has been completed having the Status TECO, CLSD. This is to understand whether proper enough materials are consumed f

  • Problem while installing oracle 9i on windows xp professional

    while installing oracle 9i iam getting strange error. the error is: Create process : null -new -sid oiddb -startmode m error=2. The problem what we figured out is ORADIM which should be under ORACLE_HOME\bin is not yet installed also some files are a

  • Reconnect of a R/3 source system afer a BW system copy

    We want to copy our BW 3.0b development system as a BW sandbox system in order to try out the BW 3.5 migration. Therefore, we performed a system copy of our BW DEV system to a new machine. On the BW-side we ran BDLS to get a new logical name for the

  • Keeping two computers files in sync?

    I have two MAC's and a family version of iLife '08. I would like to create a website using iWeb on one and have the ability to edit that site via ether of the two MAC's. Is there anyway to sync the files created by iWeb so I can edit on either comput

  • SAPSCRIPT Windows

    Dear experts, I have a standard copied Z program having an issue with output. I want to change the layout of various Windows but change option is not allowing me to drag and move windows. How do we do in sapscript ?