Need help in XSL transformation

Hi, I have a requirement where a message is recieved on the BPEL service. The message is basically a list of 200 or less productids.
The requirement is to break the incoming message into smaller messages having a list of 50 productids each and then depending on the number of smaller messages call in parrallel a Proxy service in OSB.
I am not sure how to write an XSL transfor which could split the message into smaller messages.
I would highly appreciate if somebody could help or give any pointers.

Hi,
By passing parameters you can solve your problem.
write an xsd like below.
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://schemas.oracle.com/service/bpel/common"
xmlns="http://schemas.oracle.com/service/bpel/common"
targetNamespace="http://schemas.oracle.com/service/bpel/common"
elementFormDefault="qualified">
<xsd:element name="parameters">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="item" minOccurs="1" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="value" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
create an element say pramsVar of type parameters (Root element in above xsd)
Now take an assign activity and in copy select XML fragmentand do like below
In From
<parameters xmlns="http://schemas.oracle.com/service/bpel/common">
<item>
<name>beginIndex</name>
<value/>
</item>
<item>
<name>endIndex</name>
<value/>
</item>
</parameters>
assgn the above to paramsVar.
Now assign proper values to begin and endIndexes (In your case 0 and 50)
Now pass paramsVar to XSLT and create two paramters in XSLT say beginIndex and endIndex
You need to use position function in XSLT like below
*<xsl:if test="(position() > $beginIndex ) and (position() <= $endIndex)">*
In BPEL you need to increment the beginIndex and EndIndex in a while loop till you reached the last record(In your case 4 times bcoz 200 recs)
Regards
PavanKumar.M

Similar Messages

  • Need help with XML transformation

    I am not sure this is the right place for this. But i will try it here. I am very troubled with my XSLT. Trying to transform a text Coupon which has the following html for it. So,
    _1. INPUT is:_
    <html>
    <head>
    </head>
    <body>
    <p>
    This coupon is for a good guy whose first name is :
    </p>
    <p>
    </p>
    <p align="center">
    Sadd
    </p>
    <p align="center">
    </p>
    <p align="right">
    <b>also</b> whose <var>full_name</var> is Sadd Hossain
    </p>
    <p align="left">
    </p>
    <p align="left">
    He is a <font size="3">software </font><font size="4">engineer for</font><font size="5">
    S&H</font>
    </p>
    </body>
    </html>
    *2. output needed  is:*
    <?xml version="1.0" encoding="UTF-8"?>
    <POSMESSAGE>
    <TextMSG >
    This coupon is for a good guy whose first name is :
    </TextMSG>
    <TextMSG >
    </TextMSG>
    <TextMSG align="center">
    <emph>SADD</emph>
    </TextMSG>
    <TextMSG >
    </TextMSG>
    <TextMSG align="right" >
    also whose full_name is Sadd Hossain
    </TextMSG>
    <TextMSG>
    </TextMSG>
    <TextMSG align="left" >
    He is a software engineer
    for S&H
    </TextMSG>
    </POSMESSAGE>
    *3. XSLT for this*
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <xsl:output method="xml"/>
    <xsl:template match="body">
    <POSMESSAGE>
    <xsl:for-each select="p">
    <TextMSG>
    <!--xsl:if test="not[@align='']"-->
    <xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
    <!--/xsl:if-->
    <xsl:attribute name="font"><xsl:value-of select="@size"/></xsl:attribute>
    <xsl:value-of select="."/>
    </TextMSG>
    <xsl:for-each select="b">
    <emph>
    <xsl:value-of select="."/>
    </emph>
    </xsl:for-each>
    </xsl:for-each>
    </POSMESSAGE>
    </xsl:template>
    </xsl:stylesheet>
    *4: the above xslt generating this output*
    <?xml version="1.0" encoding="UTF-8"?>
    <POSMESSAGE><TextMSG align="" font="">
    This coupon is for a good guy whose first name is :
    </TextMSG><TextMSG align="" font="">
    </TextMSG><TextMSG align="center" font="">
    SADD
    </TextMSG><TextMSG align="center" font="">
    </TextMSG><TextMSG align="right" font="">
    also whose full_name is Sadd Hossain
    </TextMSG><TextMSG align="left" font="">
    </TextMSG><TextMSG align="left" font="">
    He is a software engineer
    for S&H
    </
    *5: Need help with this. what should my xslt look like to get the desired output???????????????*
    any help or direction will be very much appreciated. Thank you_

    I have below suggestions:
    1. Please use code option given in message editor toolbar for posting any formatted content like XML, Java code snippet etc.
    2. replace & in your source XML with _& a m p ;_ (Without spaces, I have put spaces to make it visible here).
    3. I have modified your XSLT according output XML you have given. I am not sure what you want to do with some elements like <b>, <font>, <var> etc. change below XSLT as you require for these elements.
    Modified XSLT:
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
            <xsl:output method="xml"/>
         <xsl:template match="body">
              <POSMESSAGE>
                   <xsl:for-each select="p">
                        <TextMSG>
                             <xsl:if test=". != ''">
                                  <xsl:for-each select="@align">
                                       <xsl:attribute name="align">
                                            <xsl:value-of select="."></xsl:value-of>
                                       </xsl:attribute>
                                  </xsl:for-each>
                                  <xsl:value-of select="."/>
                             </xsl:if>
                        </TextMSG>
                   </xsl:for-each>
              </POSMESSAGE>
         </xsl:template>
    </xsl:stylesheet>
    OUTPUT:
    <?xml version="1.0"?>
    <POSMESSAGE>
         <TextMSG>This coupon is for a good guy whose first name is :</TextMSG>
         <TextMSG/>
         <TextMSG align="center">Sadd</TextMSG>
         <TextMSG/>
         <TextMSG align="right">alsowhose full_name is Sadd Hossain</TextMSG>
         <TextMSG/>
         <TextMSG align="left">He is a softwareengineer forS&H</TextMSG>
    </POSMESSAGE>

  • Need help in XSLT transformation

    Hi,
    I need to transform below input XML to output XML. Can you please provide any ideas for this
    Input XML :
    <?xml version="1.0" encoding="UTF-8" ?>
    <GenericCollection ParamValue="ParamValue1" xmlns="http://www.example.org">
    <Generic>
    <store>Store1</store>
    <metricName>Metric1</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store1</store>
    <metricName>Metric2</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store2</store>
    <metricName>Metric1</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store2</store>
    <metricName>Metric1</metricName>
    <metricValue>2</metricValue>
    </Generic>
    <Generic>
    <store>Store2</store>
    <metricName>Metric2</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store3</store>
    <metricName>Metric1</metricName>
    <metricValue>1</metricValue>
    </Generic>
    <Generic>
    <store>Store3</store>
    <metricName>Metric1</metricName>
    <metricValue>2</metricValue>
    </Generic>
    </GenericCollection>
    Output XML :
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <ns4:EnterpriseDocument>
    <ns4:DataSet>
    <ns4:Dimension ref_name="bu_code" value="Store1">
    <ns4:Metric ref_name="Metric1">
    <ns4:Data value="1"/>
    </ns4:Metric>
    <ns4:Metric ref_name="Metric2">
    <ns4:Data value="1"/>
    </ns4:Metric>
    </ns4:Dimension>
    <ns4:Dimension ref_name="bu_code" value="Store2">
    <ns4:Metric ref_name="Metric1">
    <ns4:Data value="1"/>
    <ns4:Data value="2"/>
    </ns4:Metric>
    <ns4:Metric ref_name="Metric2">
    <ns4:Data value="1"/>
    </ns4:Metric>
    </ns4:Dimension>
    <ns4:Dimension ref_name="bu_code" value="Store3">
    <ns4:Metric ref_name="Metric1">
    <ns4:Data value="1"/>
    <ns4:Data value="2"/>
    </ns4:Metric>
    </ns4:Dimension>
    </ns4:DataSet>
    </ns4:EnterpriseDocument>
    Thanks,
    Ramesh

    Hello Ramesh,
    Nice puzzle
    For this you need a transformation with XSLT 2.0. Use a two level grouping. First group on the store elements and the second on the metricName elements.
    Transformation looks like this:
    <?xml version="1.0"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:template match="/">
             <EnterpriseDocument>
                 <DataSet>
                     <!-- First group on the store elements
                          Each store will be grouped based on the element value
                     -->
                     <xsl:for-each-group select="/*[local-name() = 'GenericCollection']/*[local-name() = 'Generic']" group-by="./*[local-name() = 'store']">
                         <!-- For each store a Dimension element is needed -->
                         <Dimension ref_name="bu_code" value="{./*[local-name() = 'store']}">
                             <!-- Within a Dimension we need to group by metricName -->
                             <xsl:for-each-group select="current-group()" group-by="./*[local-name() = 'metricName']">
                                 <Metric ref_name="{./*[local-name() = 'metricName']}">
                                     <!-- Iterate over the metricName nodes and create a Data element -->
                                     <xsl:for-each select="current-group()/*[local-name() = 'metricValue']">
                                         <Data value="{.}"/>
                                     </xsl:for-each>
                                 </Metric>
                             </xsl:for-each-group>
                         </Dimension>
                     </xsl:for-each-group>
                 </DataSet>
             </EnterpriseDocument>
         </xsl:template>
    </xsl:stylesheet>
    Good luck!
    Regards,
    Melvin

  • Need help in message transformation.

    I need help to resolve following error during message transformation.
    ........ BaseRuntimeException: RuntimeException in Message-Mapping transformation: Cannot produce target element /ns0:BankCheckRecon_Request_MT/Header. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd at com.sap.aii.mappingtool.tf3.AMappingProgram.start.............
    <b>Note –</b> Message Map and Interface map are working correctly when tested separately in the Repository.
    <b>Mapping Rules:</b>
    /ns0:BankCheckRecon_Request_MT=/ns0:ComericaCheckRecon_Request_MT=
    /ns0:BankCheckRecon_Request_MT/Header=/ns0:ComericaCheckRecon_Request_MT/Header=
    /ns0:BankCheckRecon_Request_MT/Header/RecordID=const()
    /ns0:BankCheckRecon_Request_MT/Header/HdrNumber=const()
    /ns0:BankCheckRecon_Request_MT/Header/SenderBank=const()
    /ns0:BankCheckRecon_Request_MT/Header/ReceiverBank=const()
    /ns0:BankCheckRecon_Request_MT/Header/AcctNumber=/ns0:ComericaCheckRecon_Request_MT/Header/AcctNumber=
    /ns0:BankCheckRecon_Request_MT/Header/PymtType=const()
    /ns0:BankCheckRecon_Request_MT/Header/TapeDate=const()
    /ns0:BankCheckRecon_Request_MT/Header/ISOCurr=const()
    /ns0:BankCheckRecon_Request_MT/Item=ifWithoutElse(stringEquals(/ns0:ComericaCheckRecon_Request_MT/Detail/RecordID=, const()), /ns0:ComericaCheckRecon_Request_MT/Detail=)
    /ns0:BankCheckRecon_Request_MT/Item/RecordID=const()
    /ns0:BankCheckRecon_Request_MT/Item/ValueDate=currentDate()
    /ns0:BankCheckRecon_Request_MT/Item/ChkNumber=/ns0:ComericaCheckRecon_Request_MT/Detail/ChkNumber=
    /ns0:BankCheckRecon_Request_MT/Item/ChkAmount=/ns0:ComericaCheckRecon_Request_MT/Detail/ChkAmount=
    /ns0:BankCheckRecon_Request_MT/Item/ReceiverBank=const()
    /ns0:BankCheckRecon_Request_MT/Item/AcctNumber=const()
    /ns0:BankCheckRecon_Request_MT/Item/EncashDate=TransformDate(/ns0:ComericaCheckRecon_Request_MT/Detail/ChkPaidDate=)
    /ns0:BankCheckRecon_Request_MT/Item/TransCode=const()
    /ns0:BankCheckRecon_Request_MT/Item/AcctNumber_1=/ns0:ComericaCheckRecon_Request_MT/Detail/AcctNumber=
    <b>Test Data -</b>
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:ComericaCheckRecon_Request_MT xmlns:ns0="http://mazdausa.com/sapr3/fi/transdata/bankcheckrecon">
       <Header>
          <AcctNumber>2176975528</AcctNumber>
          <Filler1> </Filler1>
          <ReconDate>123105</ReconDate>
          <Filler2> </Filler2>
          <RecordID>H</RecordID>
          <Filler3> </Filler3>
       </Header>
       <Detail>
          <AcctNumber>2176975528</AcctNumber>
          <Filler1> </Filler1>
          <ChkNumber>0000200001</ChkNumber>
          <Filler2> </Filler2>
          <ChkPaidDate>121905</ChkPaidDate>
          <Filler3> </Filler3>
          <ChkAmount>0001020000</ChkAmount>
          <RecordID>D</RecordID>
          <Filler4> </Filler4>
       </Detail>
       <Detail>
          <AcctNumber>2176975528</AcctNumber>
          <Filler1> </Filler1>
          <ChkNumber>0000200002</ChkNumber>
          <Filler2> </Filler2>
          <ChkPaidDate>121405</ChkPaidDate>
          <Filler3> </Filler3>
          <ChkAmount>0164840000</ChkAmount>
          <RecordID>D</RecordID>
          <Filler4> </Filler4>
       </Detail>
       <Trailer>
          <AcctNumber>2176975528</AcctNumber>
          <Filler1> </Filler1>
          <ChksCount>0000000493</ChksCount>
          <Filler2> </Filler2>
          <TotalAmount>0766945400</TotalAmount>
          <Filler3> </Filler3>
          <RecordID>T</RecordID>
          <Filler4> </Filler4>
       </Trailer>
    </ns0:ComericaCheckRecon_Request_MT>
    Thanks
    Rajesh

    Thanks Mohan for your quick response. I am working with File Adapter and here are <b>Message Structures:</b>
    ComericaCheckRecon_Request_MT     
    Header     
    AcctNumber     10
    Filler1     1
    ReconDate     6
    Filler2     22
    RecordID     1
    Filler3     40
    Detail     
    AcctNumber     10
    Filler1     1
    ChkNumber     10
    Filler2     1
    ChkPaidDate     6
    Filler3     1
    ChkAmount     10
    RecordID     1
    Filler4     40
    Trailer     
    AcctNumber     10
    Filler1     1
    ChksCount     10
    Filler2     1
    TotalAmount     10
    Filler3     7
    RecordID     1
    Filler4     40
    BankCheckRecon_Request_MT     
    Header     
    RecordID     1
    HdrNumber     3
    SenderBank     15
    ReceiverBank     15
    AcctNumber     18
    PymtType     3
    TapeDate     8
    ISOCurr     3
    Item     
    RecordID     1
    ValueDate     8
    ChkNumber     13
    ChkAmount     11
    ReceiverBank     15
    AcctNumber     10
    EncashDate     8
    TransCode     3
    AcctNumber     18

  • Need Help in XSL

    I want to generate HTML from a XSD file by using XSL.
    Here is a example of how the XSD file could look.
    <?xml version="1.0"?>
    <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
    targetNamespace="http://www.publishing.org"
    xmlns="http://www.publishing.org"
    elementFormDefault="qualified">
    <xsd:element name="BookCatalogue">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Book" minOccurs="1" maxOccurs="unbounded">
    <xsd:complexType>
    <xsd:sequence>
    <xsd:element name="Title" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="Author" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="Date" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="ISBN" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    <xsd:element name="Publisher" type="xsd:string" minOccurs="1" maxOccurs="1"/>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:sequence>
    </xsd:complexType>
    </xsd:element>
    </xsd:schema>
    in other words the XSD file is variable, i.e. could be any
    file. i.e. In stead of the <xsd:element name="Book" > it could well be <xsd:element name="Baseball" >.
    So what I need is a XSL script which could dynamically process any XSD file i.e.in the code :
    value-of select="BOOK" it could be
    value-of select="a variable" an the varivble is the one which comes from the xsd file whichever is supplied.
    Any code samples or any form of help is appreciated.
    Thanks

    Well Actually,
    I need to generate the HTML with blank fields, based on the schema first, supplying a template into it.
    Then next step is of course to populate it with data from the XML file containing the actual data. That's why ...
    Thanks for ur response.
    -Ram

  • Need help on xslt transformation

    Hi ,
    I am working on a xslt transformation and  I am finding it difficult to implement the transformation. The scenario is as below.
    Input format :-
    A
    B
    B
    B
    4
    5
    A
    B
    B
    A
    B
    B
    B
    Output format :-
    A
    B
    B
    B (since after A there were 3 B’s before the next A)
    A
    B
    B(since after A there were two B’s before the next A)
    A
    B
    B
    B
    I don't need type 4,5 records in the output xml,output should have repetition of (A followed by B’s(till the next occurrences of A)).
    if some one encountered a similar transformation kindly let me know.

    Hi,
    You can use "Call" and "Apply" template.
    1st thing to do:
    e.g.
    <xsl:template name="Check_Decimal">
        <xsl:param name="Xpath"/>
        <xsl:choose>
          <xsl:when test="($Xpath) and ($Xpath)!='4'">
            <xsl:value-of select="$Xpath"/>
          </xsl:when>
          <xsl:otherwise>
            <xsl:value-of select="' ' '"/>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:template>
                <xml_Target_Element_1>
                  <xsl:call-template name="Check_Decimal">
                    <xsl:with-param name="Xpath"
                                    select="/x/y/z/xml_Target_Element_1"/>
                  </xsl:call-template>
                </xml_Target_Element_1>
    This means, it will display the value in xpath if value is not equal to 4. And if it is equal to 4, it displays nothing.
    2nd thing to do:
    Apply for-each to xpath till the String element reaches to "A".
    Regards,
    Richa

  • Help with XSL transforms

    I am new to working with Structured FrameMaker and am struggling to successfully implement an XSLT transformation. I want to transform a doxygen output in XML into a formatted FrameMaker document/book. I am using FrameMaker 7.2, and using the Using XSLT in FrameMaker 7.2 Technical Paper as a guide. I have been able to create an EDD and an application, but I am having trouble understanding how to use the EDD to format my document. Is anyone aware of other resources that can assist me?

    Unfortunately, that's the latest and greatest along with http://help.adobe.com/en_US/FrameMaker/9.0/StructuredDev/Structure_Dev_Guide.pdf (which might have a few more clues).
    Adobe has been a bit lax in updating documentation to the latest versions...
    You might also want to have a look at the Unstructed to XML workflow series of videos by Tom Aldous. The links are found on this page:
    http://www.adobe.com/devnet/framemaker.html
    See parts 4-6 for more clues.
    There's also an older book by Kay Ethier "XML and FrameMaker" (http://www.apress.com/9781590592762) that covers this and a large part of it is still applicable to current FM versions.

  • Need help in Bpel transformation

    Hi
    I am reading the xml data file through partnerlink , the receive activity is dispalying the xml record.
    I want to transform that data into target xsd.The transform activity is not getting assigned.
    Regards
    mki

    Hmmm.... That seems odd...
    You should drop a transform activity after your receive, double click and open, the drop down on the left you should choose the output variable from the receive activity, and the right side you should select the target xsd schema.
    Then on the bottom either select automapper or create mapping manually, both will open the xslt UI.

  • Need help with XML TRANSFORMATION dump

    HI Experts ,
    I want to parse this XML file to abap internal table ,i use the ST below and i get  dump .
    The file is like that :
    <Containers>
         <Container workitemid="0000001" IsParent="X">
              <Element name="__INITIATO" value="U295"/>
              <Element name="_W_PRITY" value="5"/>
              <Element name="_F_VERSION" value="0000"/>
    </Container>
    <Container workitemid="0000001">
              <Element name="EXTENDED" value="X"/>
              <Element name="NOTE_REFERENCE" value=""/>
         </Container>
    </Containers>
    An exception occurred that is explained in detail below.
    The exception, which is assigned to class 'CX_ST_MATCH_ELEMENT', was not caught
    and
    therefore caused a runtime error.
    The reason for the exception is:
    XML matching error
    Expected was element-end: "Containers" [ ] Read was element-start: "Container"
    this is the ciode that i put on the call transformation
    <Containers>
        <Container>
            <tt:loop name="a" ref=".XML_TAB">
            <Element >
              <tt:attribute name="name" value-ref="$a.name"/>
              <tt:attribute name="value" value-ref="$a.value"/>
              </Element>
              </tt:loop>
            </Container>
        </Containers> ->**the dump in the debugger is here .**
      </tt:template>
    </tt:transform>
    the dump is because i don't refer to the </Container> in the middle
    and when i try to add the tag container in the middle i get warning during complition
    any idea please im stuck
    Best Regards
    Chris
    Edited by: Chris Teb on Aug 14, 2009 6:25 PM

    I guess you'll better understand with the solution I found:
    Simple transformation:
    <?sap.transform simple?>
    <tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
      <tt:root name="XML_TAB"/>
      <tt:template>
        <Containers>
          <tt:loop name="b" ref=".XML_TAB">
            <Container>
              <tt:loop name="a" ref="$b.T_DATA">
                <Element>
                  <tt:attribute name="name" value-ref="$a.name"/>
                  <tt:attribute name="value" value-ref="$a.value"/>
                </Element>
              </tt:loop>
            </Container>
          </tt:loop>
        </Containers>
      </tt:template>
    </tt:transform>
    Program :
    data itab1 type string.
    concatenate '<Containers>'
    '       <Container workitemid="0000001" IsParent="X">'
    '   <Element name="__INITIATO" value="U295"/>'
    '   <Element name="_W_PRITY" value="5"/>'
    '   <Element name="_F_VERSION" value="0000"/>'
    '</Container>'
    '<Container workitemid="0000001">'
    '   <Element name="EXTENDED" value="X"/>'
    '   <Element name="NOTE_REFERENCE" value=""/>'
    '       </Container>'
    '</Containers>'
    into itab1.
    TYPES: BEGIN OF ty_data,
         name TYPE string,
         value TYPE string,
    END OF ty_data.
    DATA: lt_data TYPE TABLE OF ty_data.
    TYPES: BEGIN OF ty_data2,
         workitemid TYPE n LENGTH 7,
         isparent   TYPE flag,
         t_data     TYPE TABLE OF ty_data WITH DEFAULT KEY,
    END OF ty_data2.
    DATA: lt_data2 TYPE TABLE OF ty_data2.
    DATA lo_st_error TYPE REF TO cx_st_error.
    DATA message TYPE string.
    TRY.
    CALL TRANSFORMATION zext_file
            SOURCE XML itab1
            RESULT xml_tab = lt_data2.
      CATCH cx_sy_conversion_data_loss .
    * do something
      CATCH cx_st_error INTO lo_st_error.
        message = lo_st_error->get_text( ).
        WRITE:/ message .
    ENDTRY.
    By the way, I don't know what ITAB1 is in your case, it was more simple in my case to define it as a string. Anyway, if it's something else, it should work the same.

  • Need help with text() processing in XSL

    Hello,
    I have an xml that contains such text in my xml:
    before<a>inside</a>after
    and an xsl that transforms it to HTML (a cut for xsl):
    <xsl:template match="a">
    <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="text()">
    <xsl:value-of disable-output-escaping="yes" select="."/>
    </xsl:template>
    The result is: inside before after
    but I need: before inside after
    It seems it happens 'cause of this: http://www.w3.org/TR/xslt#conflict
    but I cannot find a way to solve this problem :(
    I had tried to use priority in xsl:template, but it didn't help :(
    Thanks a lot.

    DrClap
    here are xml and xsl.
    That's not a real xml and xsl, but they might describe the idea and problem. I hope I miss nothing.
    P.S. I cannot control xml, that's why I cannot use: <xsl:text> in xml.
    Thank you!
    xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <root>
    <title>Page title</title>
    <page>
    Location: <red>http://host</red>
    </page>
    </root>
    xsl:
    <?xml version='1.0' encoding='ISO-8859-1'?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:fo="http://www.w3.org/1999/XSL/Format"
    xmlns:fox="http://xml.apache.org/fop/extensions"
    exclude-result-prefixes="fo">
    <xsl:template match="root">
    <html>
    <head>
    <title>
    <xsl:apply-templates select="title"/>
    </title>
    </head>
    <body>
    <xsl:apply-templates select="page"/>
    </body>
    </html>
    </xsl:template>
    <xsl:template match="page">
    <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="title">
    [Test]: <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="red">
    <xsl:element name="span"><xsl:attribute name="style">color:red</xsl:attribute><xsl:apply-templates/></xsl:element>
    </xsl:template>
    <xsl:template match="text()">
    <xsl:value-of disable-output-escaping="yes" select="."/>
    </xsl:template>
    </xsl:stylesheet>

  • Need help in XSLT

    Hi all, I am working on xslt for the xml document which is similar to this :-
    <?xml version="1.0" encoding="UTF-8"?>
         <soapenv:Envelope      xmlns:soapenv="peopledirectory">
         *<soapenv:Header/>*
         <soap-env:Body      xmlns:soap-env="propleaccess">
         <medi:MEDI_DEV_OSB_POCOutputCollection      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:medi="http://xmlns.oracle.com/pcbpel/adapter/db/MEDI_DEV_OSB_POC">
    <medi:MEDI_DEV_OSB_POCOutput>
         <medi:STUDYID>123</medi:STUDYID>
         <medi:DOMAIN>CTS</medi:DOMAIN>
    </medi:MEDI_DEV_OSB_POCOutput>
    <medi:MEDI_DEV_OSB_POCOutput>
         <medi:STUDYID>123</medi:STUDYID>
         <medi:DOMAIN>CTS</medi:DOMAIN>
    </medi:MEDI_DEV_OSB_POCOutput>
         </medi:MEDI_DEV_OSB_POCOutputCollection>
         </soap-env:Body>
         </soapenv:Envelope>
    In the above xml if you observe the part in Bold it is an element which is closed inside the envelope with no matter in it.. I wonder how to go beyond this <Header/> element using
    xpath so as to select it in the template tag. I need the result xml should be somethiing like the below :-
    <?xml version="1.0" encoding="UTF-8"?>
         <soapenv:Envelope      xmlns:soapenv="peopledirectory">
         <soapenv:Header/>
         <soap-env:Body      xmlns:soap-env="propleaccess">
         <medi:MEDI_DEV_OSB_POCOutputCollection      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:medi="http://xmlns.oracle.com/pcbpel/adapter/db/MEDI_DEV_OSB_POC">
    <medi:MEDI_DEV_OSB_POCOutput>
    <NewElement1 name = STUDENTID value = 123/>
    <NewElement2 name = DOMAIN value = CTS/>
    </medi:MEDI_DEV_OSB_POCOutput>
    Something like this...
    To achieve this I wrote the below xslt
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:soapenv="peopledirectory" xmlns:soap-env="propleaccess          xmlns:medi="http://xmlns.oracle.com/pcbpel/adapter/db/MEDI_DEV_OSB_POC">
    <xsl:output method = "xml" intend = "yes"/>
    <xsl:template match = "soapenv:Envelope/soapenv:Header"></xsl:template>
    <xsl:template match = "soapenv:Envelope/soap-env:Body/medi:MEDI_DEV_OSB_POCOutputCollection/medi:MEDI_DEV_OSB_POCOutput" >
         <xsl:for-each select="medi:MEDI_DEV_OSB_POCOutput/medi:STUDYID">
         <xsl:element name="Name">
         <xsl:value-of select="medi:STUDYID"></xsl:value-of>
         </xsl:element>
         </xsl:for-each>
         </xsl:template>
    </xsl:stylesheet>
    Using this xslt I am not getting the result xml as how I needed. I am getting just the text values of nodes in my result xml. Kindly help me on this.
    Thanks,
    Phanindra.

    If by NewElement1, NewElement2... you mean NewElement literally (replaced by whatever real name you choose) whereas 1,2,... have no generic meaning, you can do this.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:soapenv="peopledirectory"
        xmlns:soap-env="propleaccess"
        xmlns:medi="http://xmlns.oracle.com/pcbpel/adapter/db/MEDI_DEV_OSB_POC">
    <xsl:output method = "xml" indent="yes"/>
    <xsl:strip-space elements="*" />
    <xsl:template match="*|@*|text()|processing-instruction()|comment()">
        <xsl:copy>
            <xsl:apply-templates select="*|@*|text()|processing-instruction()|comment()" />
        </xsl:copy>
    </xsl:template>
    <xsl:template match = "medi:MEDI_DEV_OSB_POCOutput" >
        <xsl:copy>
            <xsl:for-each select="*">
                <NewElement name="{local-name()}" value="{normalize-space()}" />
            </xsl:for-each>
        </xsl:copy>
    </xsl:template>
    </xsl:stylesheet>If you attach generic meaning to 1,2,... you can replace the corresponding template by this.
    <xsl:template match = "medi:MEDI_DEV_OSB_POCOutput" >
        <xsl:copy>
            <xsl:for-each select="*">
                <xsl:element name="{concat('NewElement',position())}">
                    <xsl:attribute name="name">
                        <xsl:value-of select="local-name()" />
                    </xsl:attribute>
                    <xsl:attribute name="value">
                        <xsl:value-of select="normalize-space()" />
                    </xsl:attribute>
                </xsl:element>
            </xsl:for-each>
        </xsl:copy>
    </xsl:template>I go for these details just because some technique used might help you one-day in other contexts.
    Edited by: tsuji on Feb 15, 2012 2:26 AM Essential correction made to the 2nd template.

  • XSL Transformation failure

    Here is a sample of my code:
    I initially have one (non-null & valid - checked that !) node (dataNode). I need to do a XSL transformation on this one using an xsl (non-null & valid String). I can do manually the transform using a program such as XMLSpy and everything's fine !!!
    If I pass the initial Node to transform as a String to the following function it works fine:
    * Return the transformation of an XML through an XSL
    public static String getTransformedXML(String xmlSourceString, String xslSourceString) {
    StreamSource xmlSource;
    StreamSource xslSource;
    StreamResult xmlDestination;
    StringWriter sw;
    try {
    xmlSource = new StreamSource(new StringReader(xmlSourceString));
    xslSource = new StreamSource(new StringReader(xslSourceString));
    xmlDestination = new StreamResult(sw = new StringWriter());
    Transformer thisTransformer = tFactory.newTransformer(xslSource);
    thisTransformer.transform(xmlSource, xmlDestination);
    System.out.println("xxxxx = " + sw.getBuffer());
    return sw.getBuffer().toString();
    } catch (TransformerConfigurationException e) {
    System.out.println("TRANSFORMATION CONFIGURATION ERROR:" + e.getMessage());
    return null;
    } catch (TransformerException e) {
    System.out.println("TRANSFORMATION ERROR:" + e.getMessage());
    return null;
    But I CANNOT get working this code (instead of giving a String, I give a Node):
    * Return the transformation of an XML through an XSL
    public static Node getTransformedXML(Node xmlSourceNode, String xslSourceString) {
    DOMSource xmlSource;
    StreamSource xslSource;
    DOMResult xmlDestination;
    try {
    xmlSource = new DOMSource(xmlSourceNode);
    xslSource = new StreamSource(new StringReader(xslSourceString));
    xmlDestination = new DOMResult();
    Transformer thisTransformer = tFactory.newTransformer(xslSource);
    System.out.println("avant");
    thisTransformer.transform(xmlSource, xmlDestination); // HERE IS WHERE IT CRASHES !!!!
    System.out.println("apres");
    return xmlDestination.getNode();
    } catch (TransformerConfigurationException e) {
    System.out.println("TRANSFORMATION CONFIGURATION ERROR:" + e.getMessage());
    return null;
    } catch (TransformerException e) {
    System.out.println("TRANSFORMATION ERROR:" + e.getMessage());
    return null;
    While using this function, I'm receiving the DOM Exception 3
    TRANSFORMATION ERROR:org.apache.crimson.tree.DomEx: HIERARCHY_REQUEST_ERR : This node is not allowed here !
    Also, does someone knows a way to convert a Node in a String ??? I'd like just to be able to println a node in the form "<parentNode><node1>value</node1><node2>value</node2></parentNode>" for example.
    Please help !!!!
    Thanks a lot in advance to any Java/XML Guru for helping.
    Eg\\*

    Come on ... I cannot believe that nobody saw that before. Isn't there any java/dom guru in here ;-) ?
    Could it be a possibly a bug in the API ?
    Thank you very much.
    Eg\\*

  • Xsl transformation from version1 to version2, problem with namespaces

    Guys!
    In my current project we need to have an interface in Oracle ESB which is build on lets say a wsdl version1 and an interface build on wsdl version2.
    In esb i need to define a transformation which will transform the request on version1 to version2. Because the xsd for the operation is really huge (+1000 items) i made some templates in xsl to do most of the work, works great..only i'm having a few issues now.
    To re-order items from source to target i do the next in a template
    <nameGroep>
    <xsl:copy-of select="andhere the xpath from source"/>
    <xsl:copy-of select="andhere the xpath from source"/>
    <xsl:copy-of select="andhere the xpath from source"/>
    </nameGroep>The only problem from the xsl:copy-of is, it also copies the namespace along. So if my target document uses an other namespace, it fails.
    To correct this i hoped i could make use of <xsl:namespace-alias> but this doesn't work on a literal/text tag (hope i explain this correct).
    Other option is, for every element do something like
    [code[
    <elementname>
    <xsl:value-of select=""/>
    </elementname>
    but this will create the <elementname> always in the target whether or not it's in the source. You could do a check to see if it's in the source, but this isn't a solution because then i need to check for every 1000+ item in the source document, so..we skip this idea.
    So i reach a point where im still searching for a good solution and hoped you guys could help me a bit with it.
    If the problem isn't explain well please say so, and i will add extra info.

    Guys!
    In my current project we need to have an interface in Oracle ESB which is build on lets say a wsdl version1 and an interface build on wsdl version2.
    In esb i need to define a transformation which will transform the request on version1 to version2. Because the xsd for the operation is really huge (+1000 items) i made some templates in xsl to do most of the work, works great..only i'm having a few issues now.
    To re-order items from source to target i do the next in a template
    <nameGroep>
    <xsl:copy-of select="andhere the xpath from source"/>
    <xsl:copy-of select="andhere the xpath from source"/>
    <xsl:copy-of select="andhere the xpath from source"/>
    </nameGroep>The only problem from the xsl:copy-of is, it also copies the namespace along. So if my target document uses an other namespace, it fails.
    To correct this i hoped i could make use of <xsl:namespace-alias> but this doesn't work on a literal/text tag (hope i explain this correct).
    Other option is, for every element do something like
    [code[
    <elementname>
    <xsl:value-of select=""/>
    </elementname>
    but this will create the <elementname> always in the target whether or not it's in the source. You could do a check to see if it's in the source, but this isn't a solution because then i need to check for every 1000+ item in the source document, so..we skip this idea.
    So i reach a point where im still searching for a good solution and hoped you guys could help me a bit with it.
    If the problem isn't explain well please say so, and i will add extra info.

  • XSL transformation related point

    Hi All,
    Morning, need some assistance with this issue we are facing during XSL transformation,
    During the XSL transformation we need to access mapping file lets say country-code.txt which has the details as mentioned below:
    US=USA
    UK=Great Britain
    Now when the input data value comes as US we need to map the output tag in the xsl with the value USA at run time & if input is Uk then output tag value should be Great Britain
    2.Also in another file say login-details.txt we have maintained the user-name & password like below:
    user-name='Test'
    password='welcome'
    This also we need to get the values in the xsl transformation file within the BPEL process so that at Run Time these could be got from the file ( since if we hard code in the xsl file within the BPEL process whenever the instance login details changes everytime we would have to change in the process and re deploy again)
    1.Now in Soa Suite 10g is there a way or method/steps wherein from the xslt mapping file within the BPEL process we could make a call or access these files. Also on the application server/unix directory where do we need to physically put these files at which directory location ..if this is possible.
    2.Also could a similar scenario be achieved in SOA Suite 11g
    Could someone please help us with this as we are currently stuck with this situation..
    with regards as always..

    Hi ,
    Thanks for your response first...have mentioned the details below
    ***xsl mapping ****
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:get="http://www.oracle.com/XSL/Transform/java/customclass" version="1.0">
    <FinalCountryCode>
    <xsl:variable name="countryCode" select="INPUT_COUNTRY_CODE"/>
    <xsl:value-of select="get:getCode($countryCode)"/>
    </FinalCountryCode>
    ****class defintion mentioned below****
    (this is a custom java class created where we could try accessing the file named country_code.txt and we would try calling the getCode function of this java class from the xsl mapping as above.)
    import java.io.FileInputStream;
    import java.util.*;
    public class customclass
         public static String getCode(String p_str_CountryCode)
              Properties o_countryCode = new Properties();
              String v_countryCode = null;
              FileInputStream o_Code = new FileInputStream("country_code.txt");
              o_countryCode.load(o_Code);
              v_countryCode = o_countryCode.getProperty(p_str_CountryCode);
              return v_countryCode;
    country_code.txt file would have details like this:
    US=USA
    UK=Great Britain
    So during the SOA Run time if the value for INPUT_COUNTRY_CODE comes as US the final tag CountryCode3Gid should have the value as USA
    1.Now where do we need to physically put the file name country_code.txt (having the country code mappings) on the application server in Soa 11g, so that it could be accessed during Run Time.
    2.Also where do we put customclass so that it could be accessed during SOA Run Time
    3.Also in Soa 10g & Soa 11g is there a better method or any other way/steps within Jdev and also during SOA run time that this functionality could be achieved (means call an external file which stores the mapping values which need to be referred during xsl mapping within BPEL process)
    4.We are not sure whether this would be feasible method and how to make this work in 10g as well as 11g
    thanks

  • Javax.xml.transform.TransformerException durin XSL Transformation in Java

    Hi,
    Below is my piece of code where i access a web service that returns a xml as a string. I apply a xsl tranformation on it and try to store the result as a string. I get this error message
    javax.xml.transform.TransformerException: Result object passed to ''{0}'' is invalid.
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getOutputHandler(Unknown Source)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(Unknown Source)
         at NewService.main(NewService.java:52)My Code:
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.StringReader;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.rmi.RemoteException;
    import javax.xml.namespace.QName;
    import javax.xml.rpc.ServiceException;
    import javax.xml.transform.Result;
    import javax.xml.transform.Source;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.stream.StreamResult;
    import javax.xml.transform.stream.StreamSource;
    import org.apache.axis.client.Call;
    import org.apache.axis.client.Service;
    public class NewService {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              String endPoint = "http://localhost:8080/SampleDynamicWebProj/services/SampleClient";
              Service service = new Service();
              Call callOne;
              try {
                   callOne = (Call) service.createCall();
                   callOne.setTargetEndpointAddress(new URL(endPoint));
                   callOne.setOperationName(new QName("http://DefaultNamespace",
                             "getXMLString"));
                   String concated = (String) callOne.invoke(new Object[] { "s" });
                   InputStream xsltFile = new FileInputStream("xslpackage/empTran.xsl");
                   Source xmlSource = new StreamSource(new StringReader(concated));
                 Source xsltSource = new StreamSource(xsltFile);
                 TransformerFactory transFact =
                    TransformerFactory.newInstance();
                 Transformer trans = transFact.newTransformer(xsltSource);
                 Result result = new StreamResult();
                 trans.transform(xmlSource, result);
                 System.out.println(result.toString());
              } catch (ServiceException e) {
                   e.printStackTrace();
              } catch (MalformedURLException e) {
                   e.printStackTrace();
              } catch (RemoteException e) {
                   e.printStackTrace();
              } catch (FileNotFoundException e) {
                   e.printStackTrace();
              } catch (TransformerConfigurationException e) {
                   e.printStackTrace();
              } catch (TransformerException e) {
                   e.printStackTrace();
    }I get the transformed XML into a Result object, but when i do a toString() oon it, i get the above exception.
    any help wil be appreciated,
    Dilip

    Oh well, yes it was a typo in address tag...ok agreed that its a bad example, check this out then,
    i have a XML data that i convert to a html format using xsl transformation, now this converted html has to be shown in a html page(i use the out.write option).
    so my initial xml looks like this ::
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <Results>
        <ColumnCount>6</ColumnCount>
        <Columns>
            <column>UID</column>
            <column>UserName</column>
            <column>Password</column>
            <column>LastName</column>
            <column>FirstName</column>
            <column>EmailAddress</column>
        </Columns>
        <Rows>
            <Row>
                <value>1</value>
                <value>userone</value>
                <value>password-1</value>
                <value>Anant</value>
                <value>Dilip</value>
                <value>[email protected]</value>
            </Row>
            <Row>
                <value>2</value>
                <value>usertwo</value>
                <value>password-2</value>
                <value>Palli</value>
                <value>Gilli</value>
                <value>[email protected]</value>
            </Row>
        </Rows>I apply XSL transformation on this to get a HTML which i will be writing into my output screen hoping that the user will see it in a tabular format!
    <[!CDATA["
    <?xml version="1.0" encoding="UTF-8"?>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th align="left">UID</th>
    <th align="left">UserName</th>
    <th align="left">Password</th>
    <th align="left">LastName</th>
    <th align="left">FirstName</th>
    <th align="left">EmailAddress</th>
    </tr>
    <tr>
    <td>1</td>
    <td>userone</td>
    <td>password-1</td>
    <td>Anant</td>
    <td>Dilip</td>
    <td>[email protected]</td>
    </tr>
    <tr>
    <td>2</td>
    <td>usertwo</td>
    <td>password-2</td>
    <td>Palli</td>
    <td>Gilli</td>
    <td>[email protected]</td>
    </tr>
    </table>
    "]]>The entire data is passed to a XML parser . I want the transformed xml data (which will be inside a <status></status> tag to be untouched by this parser. As you see i have put the transformed xml in a CDATA tag, but this aint helping me...
    need urgent help,
    Dilip

Maybe you are looking for

  • Is it possible to install a usb-6009 in Dasylab?

    I need to install a usb-6009 in Dasylab, but Dasylab does not recogise daqmx-devices, or so it seems. In MAX, I can see that I have traditional NI DAQ installed (7.4.2f3), but the usb devices are listed as daqmx devices. Is there any way to trick Das

  • XSL and Javascript

    I had an application running fine with the earlier Servlet version(9.6). It had Javascript embeded into the XSL stylesheet. When I moved to the new Servlet version(9.8.6), it is giving me problem . For example: this is a sample Javascriptlet inside X

  • Email Auto Complete

    I noticed that when I select " compose email" and type in for example, one letter, lets say "a", that I get a hundred or so suggestions for email recipients, that I have no idea who they are, or where they came from. It looks like most of them are be

  • Cannot import *some* mp4

    I am trying to import an mp4 video, but am receiving an error message "The importer reported a generic error". I can import this videos into other software (e.g. VLC) and I can import other .mp4s into Adobe, so it seems to be a specific video + Adobe

  • Navigation Buttons Work on and Off?

    Anyone with any suggestions would be greatly appreciated as I am out of ideas.  I am new to Flash CS4 so I may be doing something stupid.  I created my assests on Photoshop CS4 and imported them into flash as flash layers.  I followed a training vide