XSLT Help On Loop

I have an array of 2 stops that I am looping over. Each element can have multiple orders. When I map to the target there is only 1 place to put orders per stop. So I want to loop over all of the orders and concatenate them with a "|" in 1 field on the target. So the input looks like this.
<ns1:stops>
     <ns1:plannedArrival>2012-04-09T14:18:28.0000000</ns1:plannedArrival>
     <ns1:orders>
          <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
               <ns1:orderNumber>S2O1</ns1:orderNumber>
          </ns1:orderIdentity>
     </ns1:orders>
     <ns1:orders>
          <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
               <ns1:orderNumber>S2O2</ns1:orderNumber>
          </ns1:orderIdentity>
     </ns1:orders>
     <ns1:orders>
          <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
               <ns1:orderNumber>S2O3</ns1:orderNumber>
          </ns1:orderIdentity>
     </ns1:orders>
     <ns1:removeFlag>false</ns1:removeFlag>
</ns1:stops>
<ns1:stops>
     <ns1:plannedArrival>2012-04-09T15:19:39.0000000</ns1:plannedArrival>
     <ns1:orders>
          <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
               <ns1:orderNumber>S3O1</ns1:orderNumber>
          </ns1:orderIdentity>
     </ns1:orders>
     <ns1:orders>
          <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
               <ns1:orderNumber>S3O2</ns1:orderNumber>
          </ns1:orderIdentity>
     </ns1:orders>
     <ns1:orders>
          <ns1:orderIdentity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns1:OrderIdentity">
               <ns1:orderNumber>S3O3</ns1:orderNumber>
          </ns1:orderIdentity>
     </ns1:orders>
     <ns1:removeFlag>false</ns1:removeFlag>
</ns1:stops>
The target is coming out like this. With an element for each one in the loop
<ns0:Detail>
<ns0:OrderNumber>S1O1</ns0:OrderNumber>
<ns0:OrderNumber>S1O2</ns0:OrderNumber>
<ns0:OrderNumber>S1O3</ns0:OrderNumber>
<ns0:OrderNumber>S1O4</ns0:OrderNumber>
<ns0:OrderNumber>S1O5</ns0:OrderNumber>
</ns0:Detail>
I want it to look like this
<ns0:Detail>
<ns0:OrderNumber>S1O1|S1O2|S1O3|S1O4|S1O5</ns0:OrderNumber>
</ns0:Detail>
Here is the XSLT that gives the bad one.
<xsl:for-each select="ns1:orders">
<ns0:OrderNumber>
<xsl:value-of select="ns1:orderIdentity/ns1:orderNumber"/>
</ns0:OrderNumber>
</xsl:for-each>
How do I change this?

>
begin
2 loop
3 revoke select on SCHEMA.TABLENAME1 from USER
4 revoke select on SCHEMA.TABLENAME2 from USER
5 end loop;
6 end;
>
I will give you a very simple example how to grant select on an object owned by my schema to another schema.
SQL> show user
USER is "SCOTT"
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE    10.2.0.4.0      Production
TNS for 64-bit Windows: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
SQL> set serveroutput on
SQL> l
  1  begin
  2     For i in (select table_name from user_tables)
  3     Loop
  4         dbms_output.put_line('grant select on ' || i.table_name || ' to test_user; ');
  5     End Loop;
  6* End;
SQL> /
grant select on DEPT to test_user;
grant select on EMP to test_user;
grant select on BONUS to test_user;
grant select on SALGRADE to test_user;
PL/SQL procedure successfully completed.I will try to do something like this and once I am happy with the statements been generated i will replace dbms_output.put_line with execute immediate.
Until then atleast I won't use execute immediate directly on a DDL statement.
Regards
Raj
P.S : Please post like I did rather than saying it's not working which carries no value.

Similar Messages

  • Need help for loop at screen

    Hi All,
    This is Rajani. I need help on LOOP AT SCREEN statement.
    I have 3 selection blocks in the selection screen.
    First block contains two radio buttions, the second block contains 6 parameters and the third block contains 3 parameters.
    If the first radiobutton is selected, then the parameters in the third block should be grayed out.
    In the similar way for the second radiobutton.
    Please let me know my mistake from the following code :
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
      PARAMETERS : P_SALES TYPE C RADIOBUTTON GROUP G1 MODIF ID R1,
                   P_OPS   TYPE C RADIOBUTTON GROUP G1 MODIF ID R1,
                   P_MONTH TYPE SPMON OBLIGATORY MODIF ID R1.
    SELECTION-SCREEN END   OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
      PARAMETERS : P_SADIS TYPE BZIRK MODIF ID M1,
                   P_CUGRP TYPE KDGRP MODIF ID M1,
                   P_SADCH TYPE VTWEG MODIF ID M1,
                   P_SADIV TYPE SPART MODIF ID M1,
                   P_CUPAR TYPE HIEZU04 MODIF ID M1,
                   P_MAGRP TYPE MVGR1 MODIF ID M1,
                   P_PRHIE TYPE PRODH1 MODIF ID M1.
      SELECT-OPTIONS:  S_MATNR FOR S889-MATNR.
      PARAMETERS :     P_PLANT TYPE WERKS_EXT.
    SELECTION-SCREEN END   OF BLOCK B2.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.
        PARAMETERS :  P_WERKS TYPE WERKS_EXT MODIF ID M2,
                      P_MATGR TYPE PMNUX MODIF ID M2,
                      P_MRPCN TYPE DISPO MODIF ID M2.
    SELECTION-SCREEN END   OF BLOCK B3.
    *INITIALIZATION.
    AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
      IF SCREEN-GROUP1 = 'M1'.
        IF P_OPS = 'X'.
          SCREEN-INPUT = '0'.
        ENDIF.
        MODIFY SCREEN.
      ENDIF.
        IF SCREEN-GROUP1 = 'M2'.
        IF P_SALES = 'X'.
          SCREEN-INPUT = '0'.
        ENDIF.
        MODIFY SCREEN.
      ENDIF.
    ENDLOOP.

    Hi,
    This is your expected solution.
    TABLES: mara.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS : p_sales TYPE c RADIOBUTTON GROUP g1 USER-COMMAND ucom   DEFAULT 'X',  "MODIF ID r1
    p_ops TYPE c RADIOBUTTON GROUP g1 .  "MODIF ID r1
    PARAMETERS: p_month TYPE spmon OBLIGATORY ." MODIF ID r1
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
    PARAMETERS : p_sadis TYPE bzirk MODIF ID m1,
    p_cugrp TYPE kdgrp MODIF ID m1,
    p_sadch TYPE vtweg MODIF ID m1,
    p_sadiv TYPE spart MODIF ID m1,
    p_cupar TYPE hiezu04 MODIF ID m1,
    p_magrp TYPE mvgr1 MODIF ID m1,
    p_prhie TYPE prodh1 MODIF ID m1.
    SELECT-OPTIONS: s_matnr FOR mara-matnr.
    PARAMETERS : p_plant TYPE werks_ext.
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-003.
    PARAMETERS : p_werks TYPE werks_ext MODIF ID m2,
    p_matgr TYPE pmnux MODIF ID m2,
    p_mrpcn TYPE dispo MODIF ID m2.
    SELECTION-SCREEN END OF BLOCK b3.
    AT SELECTION-SCREEN.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF p_sales = 'X'.
          IF screen-group1 = 'M2'.
            screen-input = '0'.
          ENDIF.
        ENDIF.
        IF p_ops IS NOT INITIAL.
          IF screen-group1 = 'M1'.
            screen-input = '0'.
          ENDIF.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    Close this thread if you got soloution.
    Regards,
    Peranandam

  • How to configure XSLT Helper for WPC content

    Hi,
    I'm trying to write my own XSLT Helper and use it when rendering content on WPC web pages. I didn't find any documentation on this topic, so I did mimicked what SAP does with their com.sap.nw.wpc.km.service.linkmanager.XsltHelper:
    1. Wrote my little class that contains static method:
    public class MyXslHelper
         public static String testMethod()
              return "response from MyXslHelper";
    2. Added declaration of namespace and usage in xsl template:
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:my_hlp="com.my.xsl.helper.MyXslHelper">
    <xsl:value-of select="my_hlp:testMethod()"/>
    3. Defined helper in Content Management->Web Page Composer->Editor->XSLT Helpers:
    name=my_helper  
    alias=my_hlp  
    implementation=com.my.xsl.helper.MyXslHelper
    description=My helper
    PRT mode=*
    This doesnt' work and when rendered throws exception java.lang.ClassNotFoundException: com.my.xsl.helper.MyXslHelper.
    What are the steps that I'm missing? Does anyone have any documentation on how to configure xslt helpers?
    Thanks in advance
    Ruslan

    Hi
    Did you solve this issue?
    Thanks!
    Christof

  • XSLT For-each loop issue

    Hi All,
    I have a below requirement:
    two source nodes:
    <NODE1>
         <NODE2>
    Here node 2 is optional. i want to check if node 2 is present, if it is present then for-each value of node 2
    if not the the for each must be based on the value of the parent node which is node1.
    Can anyone help me out on this..
    Thanks in Advance!

    Hi,
    In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
    Sahay

  • Help with looping and counting

    i am in a CS 1 class and need help with this loop
    /*Write a program that will allow the user to enter a character
              until the capital letter Z is entered
         The program should count the number of letters entered
              and print the total after the loop is completed*/
    here is what i have it doesn't end nor does it count and i don't know hwo to make it count also i suck at do..while loops hehe
    char b,Z=0;
              Scanner a = new Scanner(System.in);
         do
                   System.out.print("Enter a letter: "+"\n");
                   b=a.next().charAt(0);
              while (b !=Z);
    i know that its not even close to being right just help me out here
    Edited by: purplesmurf on Nov 14, 2008 7:25 PM

    The following program will count the number of chacters entered until Z is enetered.
    import java.io.*;
    class count
         public static void main(String[] args)throws IOException
              char ch;
              int cnt=0;
              DataInputStream br=new DataInputStream(System.in);
              do
              System.out.print("Enter a character:");
              ch=(char)br.read();
              if(ch!='Z')
                   cnt++;
              else
                   break;
              }while((ch=(char)br.read())!='Z');
              System.out.println("The Number of entered characters are:"+cnt);
    }

  • Issue with XSLT For each loop in B2B Mapping

    Hi All,
    I am trying to map the inbound 997 Payload into Headers and Lines Table. I am using the For Each XSLT Construct to map the Loop AK2 of 997 into the 997 Lines Collection.
    Issue I am facing is that if the Loop AK2 is repeated for 33 times then for all the 33 times only its first element's value is getting passed into the target of mapping file.
    in coming payload
    <Loop-AK2>
    <Segment-AK2>
    <Element-143>810</Element-143>
    <Element-329>0001</Element-329>
    </Segment-AK2>
    <Segment-AK5>
    <Element-717>A</Element-717>
    </Segment-AK5>
    </Loop-AK2>
    <Loop-AK2>
    <Segment-AK2>
    <Element-143>810</Element-143>
    <Element-329>0002</Element-329>
    </Segment-AK2>
    <Segment-AK5>
    <Element-717>A</Element-717>
    </Segment-AK5>
    </Loop-AK2>
    <Loop-AK2>
    <Segment-AK2>
    <Element-143>810</Element-143>
    <Element-329>0003</Element-329>
    </Segment-AK2>
    <Segment-AK5>After transformation using XSLT file the payload looks like as follows
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>33</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>34</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>35</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>36</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>
    <ns0:segmentError/>
    <ns0:trxSetAckCode>A</ns0:trxSetAckCode>
    </ns0:XxmfiEdi997_AckLines>
    <ns0:XxmfiEdi997_AckLines>
    <ns0:lineId>37</ns0:lineId>
    <ns0:trxSetIdentCode>810</ns0:trxSetIdentCode>
    <ns0:trxSetControlNumber>0001</ns0:trxSetControlNumber>
    <ns0:segmentCode/>
    <ns0:segmentPosition/>the Element-329 of incoming source payload is mapped to trxSetControlNumber of target payload, the issue is obvious from the above XML data that trxSetControlNumber is always having the value 0001 for every occurence where as its expected to fetch the value of the element of its corresponding occurence not the first elements value.
    Please find below the xslt file code i used for mapping
    <ns0:XxmfiEdi997_AckHeadersCollection>
          <ns0:XxmfiEdi997_AckHeaders>
            <ns0:headerId>
              <xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_HEADERS_S","jdbc/MTSI-apps")'/>
            </ns0:headerId>
            <ns0:processFlag>
              <xsl:text disable-output-escaping="no">I</xsl:text>
            </ns0:processFlag>
             <ns0:xxmfiEdi997_AckLinesCollection>
              <xsl:for-each select="/ns1:Transaction-997/ns1:Loop-AK2">
                <ns0:XxmfiEdi997_AckLines>
                  <ns0:lineId>
                    <xsl:value-of select='oraext:sequence-next-val("XXMFI_EDI_997_ACK_LINES_S","jdbc/MTSI-apps")'/>
                  </ns0:lineId>
                  <ns0:trxSetIdentCode>
                    <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"/>
                  </ns0:trxSetIdentCode>
                  <ns0:trxSetControlNumber>
                    <xsl:value-of select="ns1:Segment-AK2/ns1:Element-329"/>
                  </ns0:trxSetControlNumber>
                  <ns0:segmentError>
                    <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Loop-AK3/ns1:Segment-AK3/ns1:Element-720"/>
                  </ns0:segmentError>
                  <ns0:trxSetAckCode>
                    <xsl:value-of select="/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK5/ns1:Element-717"/>
                  </ns0:trxSetAckCode>
                </ns0:XxmfiEdi997_AckLines>
              </xsl:for-each>
            </ns0:xxmfiEdi997_AckLinesCollection>
          </ns0:XxmfiEdi997_AckHeaders>Is there something I am doing wrong in mapping or am I missing something here. Please suggest .
    Thanks in advance
    ~TK.

    Hi,
    In your xslt code within the for loop, for the trxSetIdentCode why are you using the xpath "/ns1:Transaction-997/ns1:Loop-AK2/ns1:Segment-AK2/ns1:Element-143"? It should be just "ns1:Segment-AK2/ns1:Element-143". Similar changes for segmentError and trxSetAckCode also should be done. Remove the '/ns1:Transaction-997/ns1:Loop-AK2/' part from your xpath expressions inside the for loop and try it.
    Sahay

  • XSLT Help Required

    Hi,
    I am doing XSLT Mapping. Scenario is file to file. From input file depending on some condition I need to place records in Target file. Target File structure is:
    Header_Record (1)
    Data_Record (1..*)
    Trailer_Record (1)
    In Trailer I need to place record count of no of Data_records in this Target file.
    How should I go for this Prob.
    Looking for help.
    -Kavita

    Hi Prasanna ,
    I am not an expert but what about this:
    <SUPPLIERID>
      <xsl:value-of select="/PARTNER/PARTNRID[../PARTNRTYPE = '2002']"/>
    </SUPPLIERID>
    <BILLTOID>
      <xsl:value-of select="/PARTNER/PARTNRID[../PARTNRTYPE = '24']"/>
    </BILLTOID>or
    <xsl:choose>
      <xsl:when test="/PARTNER/PARTNRTYPE = '2002'">
        <SUPPLIERID>
          <xsl:value-of select="/PARTNER/PARTNRID"/>
        </SUPPLIERID>
      </xsl:when>
    </xsl:choose>
    <xsl:choose>
      <xsl:when test="/PARTNER/PARTNRTYPE = '24'">
        <BILLTOID>
          <xsl:value-of select="/PARTNER/PARTNRID"/>
        </BILLTOID>
      </xsl:when>
    </xsl:choose>Regards Pete

  • Problem with XML and XSLT, help...

    Okay, I have this XML doc (called stocks.xml):
    <?xml:stylesheet type="text/xsl" href="stocks.xsl" version="1.0" encoding="UTF-8"?>
    <portfolio>
    <stock>
    <symbol> SUNW </symbol>
    <name> Sun Microsystem </name>
    <price> 12.95 </price>
    </stock>
    <stock>
    <symbol> HPW </symbol>
    <name> Hewlet Packard </name>
    <price> 53.50 </price>
    </portfolio>
    And I have this XSLT doc (called stocks.xls):
    ?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xls="http://www.w3.org/TR/WD-xsl">
    <xsl:template match="/">
    <html>
    <head>
    <title> Stocks </title>
    <body bgcolor="#ffffcc">
    <xsl:apply-template />
    </body>
    </head>
    </html>
    </xsl template>
    <xsl:template match="portfolio">
    <table border="2">
    <tr>
    <th> Stock Symbol </th><th> Company Name </th><th> Price </th>
    </tr>
    <xsl:for-each select="stock">
    <tr>
    <td>
    <i><xsl:value-of select="symbol" /></i>
    </td>
    <td>
    <xsl:value-of select="price" />
    </td>
    </tr>
    </xsl:for-each>
    </table>
    </xsl template>
    </stylesheet>
    When I try to retrieve the stocks.xml document with
    IE, the browser said, there is an error on line 2, can not
    recognize xsl:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Reference to undeclared namespace prefix: 'xsl'. Error processing resource 'http://localhost:8080/examples/jsp/stocks/stocks.xsl'. Line 2, Position 71
    <xsl:stylesheet version="1.0" xmlns:xls="http://www.w3.org/TR/WD-xsl">
    I just follow this from an example of XML tutorial.
    Please help, what is it that I miss? Seems everything
    I have is okay....??
    Thanks,
    Ted.

    Thanks you all!
    You have spotted that mistyped.
    However, turns out Internet Browser that I have does not permit the use of XSL. After I fixed the file, I got this
    message:
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
    Keyword xsl:apply-template may not be used here.
    Oh well...
    Anybody knows, if IE can or can not be used to view the
    XML that reference XSL??
    Thanks,
    Ted.

  • XSLT help to transform an XML

    I need help writing and XSLT to transform an XML in InDesign.  I am new to XML and have no idea how to write an XSLT.
    We are trying to bring in data from a database using a query language that is having trouble creating the image tags the way we need it to.  Basically, I need to take this:
    <Project href="file://C:\My test phot.jpg">
    and transform it into this:
    <Project> <image href="file://C:\My test phot.jpg" />
    Can anyone help me with this?
    Thanks!

    Not sure I can help you with this, as my understanding of XSL is very limited.
    However, as a matter of trial and error, I find that if I transform this XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
         <Project href="file://C:\My test phot1.jpg">The first bit of textual content here</Project>
         <Project href="file://C:\My test phot2.jpg">The second bit of textual content here</Project>
         <Project href="file://C:\My test phot3.jpg">The third bit of textual content here</Project>
         <Project href="file://C:\My test phot4.jpg">The fourth bit of textual content here</Project>
         <Project href="file://C:\My test phot5.jpg">The fifth bit of textual content here</Project>
    </Root>
    ...with this XSLT:
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
       <xsl:template match="/">
         <Root>
             <xsl:for-each select="/Root/Project">
               <Project>
                 <image><xsl:attribute name="href"><xsl:value-of select="@href"/></xsl:attribute></image>
                 <xsl:value-of select="."/>
               </Project>
             </xsl:for-each>
         </Root>
       </xsl:template>
    </xsl:stylesheet>
    ...I end up with this XML:
    <?xml version="1.0" encoding="UTF-8"?>
    <Root>
    <Project><image href="file://C:\My test phot1.jpg"/>The first bit of textual content here</Project>
    <Project><image href="file://C:\My test phot2.jpg"/>The second bit of textual content here</Project>
    <Project><image href="file://C:\My test phot3.jpg"/>The third bit of textual content here</Project>
    <Project><image href="file://C:\My test phot4.jpg"/>The fourth bit of textual content here</Project>
    <Project><image href="file://C:\My test phot5.jpg"/>The fifth bit of textual content here</Project>
    </Root>
    ...which seems what you're looking for.
    [I edited the original solution slightly by removing a wildcard.]

  • XSLT help

    I've used XSLT quite a bit to transform one form of XML into another, or into HTML, or into a programming language.
    So I'm OK on the basic syntax.
    Now I want to do some very simple automated editing of an XML file. I just want to add a few child elements to an element.
    Perhaps I'm being dim, but how on earth would I go about that? I just want to select an element with match="method[@name='asp_bk_consmt_io]'" and add a few elements to it, and output the result to the out file.
    So the fragment
    <method name="asp_bk_consmt_io">
    </method>becomes
    <method name="asp_bk_consmt_io">
      <param name="p_principal" type="structure" structureName="Asp_bk_party"/>
    </method>And the rest is copied unchanged. Can anyone help?

    <xsl:template match="method">
    <method>
    <xsl:attribute name="name">
    <xsl:value-of select="@name"/>
    </xsl:attribute>
    <xsl:if test="method[@name='asp_bk_consmt_io']">
    <param name="p_principal" type="structure" structureName="Asp_bk_party"/>
    </xsl:if>
    </method>
    </xsl:template>
    I think that will work. There is an excellent XSLT tutorial and reference at www.zvon.org.
    - Saish

  • Help with loop in code

    I have the following servlet which connects to a database and should brgin back the name of all films that an actor has stared in below is part of the servlet my problem is each time i run the servlet it just prints out "sorry there has been an error" a number of times. Can any body help me get this working?
    public static int MAX_COUNT = 100;
    int curr_item = 0;
    private static CatalogItem addedItem[] = new CatalogItem[MAX_COUNT];
    private static CatalogItem items[] = new CatalogItem[MAX_COUNT];
    CatalogItem item;
    CatalogItem details;
    public static CatalogItem getItem(int recordingid) {
               CatalogItem item;
              for(int i=0; i<items.length; i++) {
                item = items;
              addedItem[i] = items[i];
    if (recordingid==item.getrecordingid()) {
    return(item);
    return(null);
    // Database connection
         int recordingidDB;
         String directorDB;
         String titleDB;
         String categoryDB;
         String imageDB;
         int durationDB;
         String ratingDB;
         String yearDB;
         float priceDB;
         int StockDB;
         Connection conn = null;
         try{
         Class.forName("com.mysql.jdbc.Driver").newInstance();
         } catch(Exception e) {
         System.out.println(e);
         try{
         conn = DriverManager.getConnection
    ("jdbc:myurl");
         // System.out.println("Connection to database successful.");
    catch(SQLException se) {
         System.out.println(se);
         try{
                   String category = request.getParameter("category");
         String selectSQL = "select recording_id, director, title, category, image_name, duration, rating, year_released, price, stock_count "+
         "from video_recordings " +
                        "where recording_id IN "+
                        "(select recording_id "+
                        "from video_actors "+
                        "where name ='"+request.getParameter("category")+"')";
    System.out.println(selectSQL);     
         Statement stmt = conn.createStatement();
         ResultSet rs1 = stmt.executeQuery(selectSQL);
         while(rs1.next() && curr_item < MAX_COUNT){
              recordingidDB = rs1.getInt("recording_id");
              directorDB = rs1.getString("director");
              titleDB = rs1.getString("title");
              categoryDB = rs1.getString("category");
              imageDB = rs1.getString("image_name");
              durationDB = rs1.getInt("duration");
              ratingDB = rs1.getString("rating");
              yearDB = rs1.getString("year_released");
              priceDB = rs1.getFloat("price");
              StockDB = rs1.getInt("stock_count");
         item =
              new CatalogItem
              (recordingidDB, directorDB, titleDB, categoryDB, imageDB, durationDB, ratingDB, yearDB, priceDB, StockDB);
              addedItem[curr_item] = item;
    items[curr_item++] = item;
    int ITEM_COUNT = curr_item;
         String pagetitle = "Catalog Items";
    out.println(
    "<BODY BGCOLOR=\"#a00e0e\">\n" +
              "<center></center>\n" +
    "<H1 ALIGN=\"CENTER\">" + pagetitle + "</H1>\n");
         // loop to go over each item in the array of catalogItem
         for(int i=0; i<addedItem.length; i++) {
         details = items[i];
         if (details == null) {
    out.println("SORRY THERE HAS BEEN AN ERROR ");
         } else {  
              for(int j=0; j<MAX_COUNT; j++) {
    out.println(
    addedItem[j].gettitle() + "\n" +
    addedItem[j].getprice() + "\n" +
    addedItem[j].getstock() + "\n" );
         out.println("</BODY></HTML>");
         stmt.close();
         conn.close();
         } catch(SQLException se) {
         System.out.println(se);

    ok..
    1. To print the size of the resultset there is no direct way from wat i know so far. You need to work around it. This wat i normally do for testing:
    String selectSQL = "select count(video_recordings.recording_id) " +
                                "from video_recordings " +
                        "where recording_id IN "+
                                                 "(select recording_id "+
                                                "from video_actors "+
                                                 "where name ='"+request.getParameter("category")+"')";
    Statement stmt = con.createStatement() ;
    ResultSet rs = stmt.executeQuery(selectSQL) ;
    rs.next() ;
    BigDecimal rowCount = rs.getBigDecimal(1) ;
    System.out.println("Result size = " + rowCount.toString());The rowCount variable now contains the size of your query result.
    2. To print the stacktrace, just add in se.printStackTrace into your catch blocks.
    Additional: Can u also print something inside youe while loop to confirm that your code did enter the while loop and perform the assignment?
    Maybe u can also print the addedItem[curr_item] value after you addedItem[curr_item] = item to confirm that the item was successfully assigned to addedItem[curr_item]..

  • Help with Loop Function

    I am trying to automate converting Pages documents to Word. Maybe later to reopen them in Pages but with the options set to create flat files.
    I select the files I want and they open ok. The export goes ok and I click the file close button,
    Maybe this close does not work as I get twice as many files open after each loop.
    How do I stop the loop function bringing all the files in again each time.?
    Get Selected Items
    Open Finder Items
    Watch Me Do:
    Click "Pages" in the Dock
    Click the "File" menu
    Export
    Click the "Next..." button
    Click the "<fill the title>" button
    Loop (use the current results as input)
    Your help would be welcome!
    Message was edited by: putnik

    Thanks again,
    The "Dispense Items Incrementally" seems to work well enough. However, now the workflow stops at the end of the second loop. The file is closed but the "Watch Me" function seems to want something else to happen (it continues active). The only first file is still listed in the loop function.
    Get Selected Items
    Dispense Items Incrementally
    Open Finder Items
    Watch Me Do:
    Click "Pages" in the Dock
    Click the "File" menu
    "Export"
    Type '
    Type '
    <Cmd W>
    Loop (up to 10 times, use the current results as input)
    Note that I am learning to avoid mouse gestures where possible as things move about to much...
    Any idea what I need to do?

  • XSLT Help Request - Building Hierarchy

    Hi everyone,
    We are receiving a file that has the following structure, where fields that start with H are header fields, and fields that start with D are detail fields (like a header and line items in an FI posting).
    H1, H2, H3, D1, D2, D3, D4, D5
    On the first line of the FI posting, the H and the D fields are populated (i.e. contains the header information, and the first line item information).  Then on the next lines, the H fields are all blank, and the D fields are populated.  So like this:
    H1, H2, H3, D1, D2, D3, D4 (for line item 1)
    , , ,D1, D2, D3, D4 (for line item 2)
    The file can also have more than 1 FI posting (i.e. more than 1 Header):
    H1, H2, H3, D1, D2, D3, D4 (for line item 1)
    , , ,D1, D2, D3, D4 (for line item 2)
    H1, H2, H3, D1, D2, D3, D4 (for line item 1)
    , , ,D1, D2, D3, D4 (for line item 2)
    We are trying to map this into a FIDCC1 idoc posting, which looks like this:
    <FIDCCP01>
      <IDOC>
        <Header>
          <H1></H1>
          <H2></H2>
          <H3></H3>
          <Item><D1></D1><D2></D2><D3></D3><D4></D4></Item>
          <Item><D1></D1><D2></D2><D3></D3><D4></D4></Item>
        </Header>
      </IDOC>
      <IDOC>
        <Header>
          <H1></H1>
          <H2></H2>
          <H3></H3>
          <Item><D1></D1><D2></D2><D3></D3><D4></D4></Item>
          <Item><D1></D1><D2></D2><D3></D3><D4></D4></Item>
        </Header>
      </IDOC>
    </FIDCCP01>    
    We can't make this work alone in the concent conversion, so was thinking that this could be done in XSLT.  We have created a data type that contains the fill H and D fields and are taking this into XI no problems, but we are having problems putting it into the hierarchy.  Any help is greatly appreciated.
    Thanks
    Peter

    Here is the input file, top line being the field breakdown
    12222333333334444566666666666666667777777777777777
    1FB0104052007ARP 20000000026590.000000000000000.00
    /////////////////20000000098765.000000000000000.00
    1FB0104052007USD 20000000012345.000000000000000.00
    /////////////////20000000054321.000000000000000.00
    Field 1, when it is a "1", is the start of the header line.  Field 5 will always be a "2", and is the start of the detail line.  Also all null fields are populated with a slash.
    My idea was to take this in all on 1 line where the structure contains both the header and the detail fields, because I wasn't sure if content conversion could do what I wanted.  When I do that, here is the result:
    <?xml version="1.0" encoding="utf-8"?>
    <ns:IFS_MT xmlns:ns="http://xx.com/xi/fin/gl/iams/ifs">
         <Detail>
              <STYPE1>1</STYPE1>
              <TCODE>FB01</TCODE>
              <BLDAT>04052007</BLDAT>
              <WAERS>ARP</WAERS>
              <STYPE2>2</STYPE2>
              <WRBTR>0000000026590.00</WRBTR>
              <DMBE2>0000000000000.00</DMBE2>
         </Detail>
         <Detail>
              <STYPE1>/</STYPE1>
              <TCODE>////</TCODE>
              <BLDAT>////////</BLDAT>
              <WAERS>////</WAERS>
              <STYPE2>2</STYPE2>
              <WRBTR>0000000098765.00</WRBTR>
              <DMBE2>0000000000000.00</DMBE2>
         </Detail>
         <Detail>
              <STYPE1>1</STYPE1>
              <TCODE>FB01</TCODE>
              <BLDAT>04052007</BLDAT>
              <WAERS>USD</WAERS>
              <STYPE2>2</STYPE2>
              <WRBTR>0000000012345.00</WRBTR>
              <DMBE2>0000000000000.00</DMBE2>
         </Detail>
         <Detail>
              <STYPE1>/</STYPE1>
              <TCODE>////</TCODE>
              <BLDAT>////////</BLDAT>
              <WAERS>////</WAERS>
              <STYPE2>2</STYPE2>
              <WRBTR>0000000054321.00</WRBTR>
              <DMBE2>0000000000000.00</DMBE2>
         </Detail>     
    </ns:IFS_MT>
    I am open to changing the file content conversion if there is a better way!
    The desired result is:
    <FIDCCP01>
         <IDOC>
              <E1FIKPF>
                   <TCODE>FB01</TDOCE>
                   <BLDAT>04052007</BLDAT>
                   <WAERS>ARP</WAERS>
                   <E1FISEG>
                        <WRBTR>0000000026590.00</WRBTR>
                        <DMBE2>0000000000000.00</DMBE2>
                   </E1FISEG>
                   <E1FISEG>
                        <WRBTR>0000000098765.00</WRBTR>
                        <DMBE2>0000000000000.00</DMBE2>
                   </E1FISEG>
              </E1FIKPF>
         </IDOC>
         <IDOC>
              <E1FIKPF>
                   <TCODE>FB01</TDOCE>
                   <BLDAT>04052007</BLDAT>
                   <WAERS>USD</WAERS>
                   <E1FISEG>
                        <WRBTR>0000000012345.00</WRBTR>
                        <DMBE2>0000000000000.00</DMBE2>
                   </E1FISEG>
                   <E1FISEG>
                        <WRBTR>0000000054321.00</WRBTR>
                        <DMBE2>0000000000000.00</DMBE2>
                   </E1FISEG>
              </E1FIKPF>
         </IDOC>
    </FIDCCP01>
    Thanks again!
    Peter

  • SOS beginner needs XSLT help

    Hello,
    I have an XML document that does not have any space between brackets as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <root><One><a>toto</a><a>titi</a></One><One><a>tata</a><a>tutu</a></One></root>I have been looking for an XSLT script that would give me that:
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
        <One>
            <a>toto</a>
            <a>titi</a>
        </One>
        <One>
            <a>tata</a>
            <a>tutu</a>
        </One>
    </root>or something more human-readable that the first example. Is that possible?
    I have been working on that all day long without much success as I am a beginner in xslt. Any help or clue immensely welcome!!
    Julien.

    Hello DrClap,
    Thanks a lot!! It works partially insomuch as it puts a carriage return and gives me that:
    <root>
    <One>
    <a>toto</a>
    <a>titi</a>
    </One>
    <One>
    <a>tata</a>
    <a>tutu</a>
    </One>
    </root>Has anyone got any clue as to how to configure xalan on NB so that it indents the xml properly??
    Julien.

  • Help withe loop on tables

    Hallow in my table itab I have employee (sobid employee number and names ex. 80 emp) in my loop(b_itab) I get all he employee that doing the course (their sobid just 3 emp) how can I use b_itab to write to other table (d_itab) to write all the employee that don’t doing the course .I need a  general solution.
    <b>Ex.i have a table with 80 emp and I doing a loop on this table and find 3 employee that doing course how can I do  comparison in the 2 table that if the employee not in b_itab(emp doing course) write them in d_itab(oteer table).</b>    .if u need more details  please let me now.
    regards

    Loop at itab.
    Specify the condition here if they are doing the course
    if (Condition here)
    append itab to b_itab.
    else
    append itb to d_tab.
    endif.
    endloop.
    The other option will be:
    loop at itab.
    read table b_itab with key course = itab-course.
    if sy-subrc NE 0.
    append itab to d_itab.
    endif.
    endloop.
    Can you try these options? If not, please give the structure of the internal table to know exactly you want to do.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

Maybe you are looking for