How to Supress null target Elements in XSLT Mapping

Hi Experts,
I need to Strip off (remove) Null tags from my ouput XML document.
My XSLT Mapping file
<?xml version='1.0' ?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<a:A2ACU>
<a:PartNo>
<xsl:value-of select="Specifications/Specification/PARTNO"/>
</a:PartNo>
<a:Revision>
<xsl:value-of select="Specifications/Specification/REVISION"/>
</a:Revision>
<a:ENERGY>
<xsl:for-each select="Specifications/Specification/Section">
<xsl:variable name="Sec_ID">
<xsl:value-of select="SECTIONID"/>
</xsl:variable>
<xsl:if test="$Sec_ID = '700015'">
<xsl:for-each select="Item">
<xsl:variable name="Item_ID">
<xsl:value-of select="ITEMID"/>
</xsl:variable>
<xsl:if test="$Item_ID = '701134'">
<xsl:for-each select="PropertyGroup/Property">
<xsl:variable name="Pro_ID">
<xsl:value-of select="PROPERTYID"/>
</xsl:variable>
<xsl:if test="$Pro_ID = '700232'">
<xsl:variable name="Atr_ID">
<xsl:value-of select="ATTRIBUTEID"/>
</xsl:variable>
<xsl:if test="$Atr_ID = '700064'">
<xsl:value-of select="STRING2"/>
</xsl:if>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</a:ENERGY>
</a:A2ACU>
</xsl:template>
</xsl:stylesheet>
If any one of the condition in ENRGY TAG FAILS it is giving a output as
- <A2ACU>
<PartNo>123456789</PartNo>
<Revision>2</Revision>
<ENERGY></ENERGY>
- </A2ACU>
But as per my new requirement I need to check the Empty value in all the tags and need to strip of them form final output ...like..
- <A2ACU>
<PartNo>123456789</PartNo>
<Revision>2</Revision>
- </A2ACU>
Can any one please suggest me whether any function is availble to this stripping
Thanks in Advance
Ram

Hi Ram,
try to put the tag inside the IF conditions.
It'd be something like:
> <xsl:for-each select="Specifications/Specification/Section">
> <xsl:variable name="Sec_ID">
> <xsl:value-of select="SECTIONID"/>
> </xsl:variable>
> <xsl:if test="$Sec_ID = '700015'">
> <xsl:for-each select="Item">
> <xsl:variable name="Item_ID">
> <xsl:value-of select="ITEMID"/>
> </xsl:variable>
> <xsl:if test="$Item_ID = '701134'">
> <xsl:for-each select="PropertyGroup/Property">
> <xsl:variable name="Pro_ID">
> <xsl:value-of select="PROPERTYID"/>
> </xsl:variable>
> <xsl:if test="$Pro_ID = '700232'">
> <xsl:variable name="Atr_ID">
> <xsl:value-of select="ATTRIBUTEID"/>
> </xsl:variable>
> <xsl:if test="$Atr_ID = '700064'">
> <a:ENERGY><xsl:value-of select="STRING2"/></a:ENERGY>
> </xsl:if>
> </xsl:if>
> </xsl:for-each>
> </xsl:if>
> </xsl:for-each>
> </xsl:if>
> </xsl:for-each>
Regards,
Henrique.

Similar Messages

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

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

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

  • How to insert new line break in XSLT mapping

    Hi experts,
    I am doing file to mail scenario, i am sending the text file as an attachment using reciever mail adapter.
    I did everything, i can able to send the mail with text file attachment, but with in the file i got multiple rows, i need to put line break in XSLT mapping.
    I did use following statement but it is inserting small rectangle between the records, the records are not separating with new lines, all are in one line.
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    Can anyone suggest me how to insert new line in XSLT mapping.
    My XSLT mapping as look like:
    <?xml version='1.0'?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:ns0="http://www.Coj.co.za/SapIsuToABSA/DirectDebitFile">
    <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
    <xsl:variable name="break">&lt;br/&gt;</xsl:variable>
    <xsl:variable name="space"> </xsl:variable>
    <xsl:variable name="newline"><xsl:text></xsl:text></xsl:variable>
    <xsl:template match="/">
    <ns1:Mail xmlns:ns1="http://sap.com/xi/XI/Mail/30">
    <Subject>Please Check Attached Direct Debit File</Subject>
    <From>S@za</From>
    <To>P@za</To>
    <Content_Type>text/plain</Content_Type>
    <Content>
    <xsl:for-each select="MT_SapIsuToABSA_DirectDebitFile/DirectDebitRec/Body">
    <xsl:value-of select="Space1"/>
    <xsl:value-of select="Cust_AccNo"/>
    <xsl:value-of select="Reserve_1"/>
    <xsl:value-of select="Cust_Name"/>
    <xsl:value-of select="Cust_Name1"/>
    <xsl:value-of select="Cust_Bank_AccNo"/>
    <xsl:value-of select="Space2"/>
    <xsl:value-of select="Cust_Bank_BranchNo"/>
    <xsl:value-of select="Reserve_2"/>
    <xsl:value-of select="Space3"/>
    <xsl:value-of select="Cust_AccNo_1"/>
    <xsl:value-of select="Space4"/>
    <xsl:value-of select="Reserve_3"/>
    <xsl:value-of select="Deduction_Amnt"/>
    <xsl:value-of select="Space5"/>
    <xsl:value-of select="Reserve_4"/>
    <xsl:value-of select="Space6"/>
    <xsl:value-of select="Action_Date"/>
    <xsl:value-of select="Space7"/>
    <xsl:value-of select="Reserve_5"/>
    <xsl:text>*#xA;</xsl:text>   
    note: in real coding replace * with &
    </xsl:for-each>
    </Content>
      </ns1:Mail>
      </xsl:template>
      </xsl:stylesheet>
    Kind regards,
    Praveen

    Hi,
    I think <xsl:text>#xa;</xsl:text> should do the trick, but depending on which OS (ux or win), the "new line" chars sequence is different (win would require a CRLF like <xsl:text>#xd;*#xa;</xsl:text>)
    Chris
    -> &
    Edited by: Christophe PFERTZEL on Apr 14, 2010 2:16 PM

  • ** How to get Source File Name thru XSLT Mapping

    Hi friends,
    We require source file name after message processing (SXMB_MONI) in the output structure.  We understad from Forums and  blog 2664, this is possible thru UDF - DynamicConfiguration class. This UDF will work if we use message mapping. But, in our case we are using XSLT mapping. So, how do we call  the same from Java Pacakage ? (Imported Archives). For writing java class separately, what are the changes to be made in the program?
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return ourSourceFileName;
    Kindly reply, friends.
    Kind Regards,
    Jeg P.

    Hi,
    This is the example in this similar manner u have to call the method in which u have to write the code for picking the source file name.
    <name>
       <xsl:if test="function-available('javamap:concat')">
        <xsl:value-of select="javamap:concat($first, $last, $inputparam)"/>
       </xsl:if>
      </name>
    for reference check the Link,
    http://help.sap.com/saphelp_nw04s/helpdata/en/73/f61eea1741453eb8f794e150067930/frameset.htm
    Regards,
    Phani

  • How to call external java functions in XSLT Mapping Programs

    Hi All,
    I am unable to call java programs in XSLT MAPPING.
    I tried by following the blog...but getting error :
    XSLT Mapping With JAVA Enhancement ( For Beginners)
    I need some input from you all.
    Waiting For quick reply.
    Rgds Somu.

    i wrote the code...
    and getting error in interface mapping..
    <?xml version="1.0"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:MyLib="java:datetime.DateandTime">
         <xsl:template match="/">
              <Order DocType="OrderCreate" Version="2.0.2">
                   <Header>
                        <RequestingDocumentIdentifier>
                             <DocumentIdentifier>
                                  <xsl:value-of select="concat('IDOC',//EDI_DC40/DOCNUM)"/>
                             </DocumentIdentifier>
                        </RequestingDocumentIdentifier>
                        <RequestingDocumentDateTime>
                             <DateTime DateTimeQualifier="On">
                                            <xsl:if test="function-available('MyLib:getDateValue')">
                       <xsl:value-of select="MyLib:getDateValue()"/>                   
      </xsl:if>
                                        </DateTime>
                        </RequestingDocumentDateTime>
                        <From>
                             <PartnerInformation>
                                   <PartnerName>BASF SA</PartnerName>
                                    <PartnerIdentifier Agency="AssignedByBASF">
                                     <xsl:value-of select="//E1EDK14[QUALF='014']/ORGID"/>
                                    </PartnerIdentifier>
                             </PartnerInformation>
                        </From>
                        <To>
                        <PartnerInformation>
                             <PartnerName>BASF CORP CHEM DIV</PartnerName>
                             <PartnerIdentifier Agency="D-U-N-S">001307032</PartnerIdentifier>
                        </PartnerInformation>
                   </To>
                   </Header>
              </Order>
         </xsl:template>
    </xsl:stylesheet>

  • How we can view convert data after XSLT mapping & before Graphical mapp

    Hello Friends,
    Currently i am working on XI standard content. In this client need some customization.
    In interface mapping, XSLT mapping on 1st position & Graphical mapping on 2nd position.
    As per my understanding 1st XSLT mapping will be exected then Graphical mapping.
    Can I see or check convert data from XSLT mapping.
    I want to check data between XSLT mapping & Graphical mapping.
    Kindly help me out.
    Regards,
    Narendra

    >
    Narendra GSTIT wrote:
    > I dont want to test standalone XSL Code.
    >
    > The data which I get from Source interface and after XSLT mapping I want to check this that my XSLT code is going well or not.
    >
    > i.e. check for proper input & get proper output.
    You have ro do standalone testing of the XSLT mapping.....Interface Mapping or Interface Determination will give you output message which will be that of message mapping (the last mapping)
    What is the issue in testing the XSLT mapping alone?...may be in Stylus Studio.
    Just ensure that XSLT mapping produces proper output and then this output message of XSLT is the input to your Message Mapping.....once the entire Interface mapping gets executed then it would mean that all the included mapping programs work fine.
    Regards,
    Abhishek.

  • How to insert spaces in elements in message mapping

    Hi All,
             I have scenario, where in the incoming data is put into a file, but if there is no incoming data for any element it should insert spaces equivalent to the lenght of the field. how can this be done?
    XIer

    Xier,
    your problem is that the MapWithDefault function will fill only the fields which have no value, for example, if that tag is like <field2/>. When you have <field2></field2>, you have a value, even though this value is an empty string.
    To test your scenario properly, change your input xml to:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:MT_Countresult xmlns:ns0="urn:sce.com:xi:FI:TestProjectStructureUpload">
         <record>
              <field1>a</field1>
              <field2/>
              <field3>b</field3>
         </record>
    </ns0:MT_Countresult>
    If your requirement is to insert spaces when you have empty string as the input (<field2></field2> case), then you can't use MapWithDefault. In this case, you have to use an if logic: if input = "" (empty string) then output = "    " (4 blankspaces), else output = input.
    If you don't know how the input will come, best scenario would be to combine the MapWithDefault + If logic, in order to solve both cases (no input or empty string input).
    Regards,
    Henrique.

  • How to put identical target value in value mapping table

    Hi all ,
             I am implementing a value mapping function .Problem is occuring for repetated target value.for ex: if key is GL001 GL002 GL003  and destination value is 4 5 4 then its creating problem for identical values i.e for  both GL001 & GLOO3 its not accepting 4 .Same manner for many diffrent glncode i have  identical values.not understanding how to deal with these identical values please guide me as its very urgent.
    Regards,
    Saurabh

    Hi saurabh,
    you can try this out....
    First you create a value mapping table in ID like:
    AWSYS   GLNCODE
    GLOO1     10
    GLOO2     20
    (without GLOO3).
    now in your message mapping do the following mapping:
                              Contant[GLOO1]
                                   |
                                   |(then)
    AWSYS-------------> equals---->if----------------->Value Mapping---->GLNCODE
                        |          |(else)
                        |          |
    Constant[GLOO3]-----|        AWSYS
    **Reward points if helpful...
    --Sankar Choudhury

  • How to implement multi-source XSLT mapping in 11g PS3 BPEL  ?

    Hi
    How to implement multi-source (single destination) XSLT mapping in 11g PS3 BPEL ? Is there any good example step by step ?
    thx
    d

    Hi d,
    Also there's a sample available at samplecode.oracle.com mapper-105-multiple-sources.zip.
    Regards,
    Neeraj Sehgal

  • SOAP Header XSLT mapping

    Hi,
    I am working on Proxy to SOAP synchronous scenario.  How to create SOAP header message in XSLT mapping...I am trying but no sauces becz receiver side SOAP header and Body in different message types please see below.
    Header part is message type 1
    <CredentialsHeader xmlns="http://reuters.com/datascopeselect/ExtractionService/v1/">
          <Username>string</Username>
          <Password>string</Password>
          <AuthenticationToken>string</AuthenticationToken>
        </CredentialsHeader>
    Body part is
    message type 2
    <soap:Body>
        <Extract xmlns="http://reuters.com/datascopeselect/ExtractionService/v1/">
          <request>
            <OutputFields>
              <string>string</string>
              <string>string</string>
            </OutputFields>
          </request>
        </Extract>
      </soap:Body>
    </soap:Envelope>
    But source is single.. I try ed multi mapping but synchronous scenario it will not working. 
    I am trying to generate both message types as single message type in XSLT mapping target side and will give service interface as dummy in ESR.
    Please guide how to generate 2 message types as single message type in XSLT mapping...
    Thanks,
    Venkat

    Hi Venkat,
    I suggest to produce a complete SOAP message in message mapping. Import the SOAP XSD from [http://schemas.xmlsoap.org/soap/envelope/] as external definition and use it as target message in message mapping. You need at 2 mapping programs in order to produce the message. The first mapping creates header and body. In the second mapping use "Return as XML" to map the header and body nodes to the SOAP envelope.
    In the SOAP receiver communication channel, you need to activate the parameter "Do Not Use SOAP Envelope", see [Configuring the Receiver SOAP Adapter|http://help.sap.com/saphelp_nw04/helpdata/en/29/5bd93f130f9215e10000000a155106/content.htm].
    Regards, Martin

  • How to supress target side mandatory node

    Hi Guys,
    Can any throw some light on this plese, How to supress mandatory (1..Unbound) on Target side.
    Great help to me!!
    Regards
    San

    Neetesh Raj wrote:>
    > San,
    > >
    > >
    > > Refer Sarvesh's reply. In my previous reply, I had meant similar approach.
    > >
    > >
    > > Regards,
    > > NeeteshHi Guys,
    Please have a look the both structures and give me your idea on this!!
    Source
    ROOT     Complex Type          
    OUTPUT                          Element          0..unbounded
    TRANS_HEADER     Element          0..unbounded
    SET_ID                          Element     xsd:string     0..1
    H01_XQ                          Element          0..unbounded
    XQ01                          Element     xsd:string     0..1
    XQ_Y2K_D                      Element     xsd:date     0..1
    Group_N1                        Element          0..unbounded
    H02_N1                          Element          0..1
    N101                          Element     xsd:string     0..1
    Group_LIN                        Element          0..unbounded
       D01_LIN                          Element          0..unbounded
          LIN02                          Element     xsd:string     0..1
       D01_PO4                          Element          0..unbounded
          P0401                          Element     xsd:integer     0..1
       D01_N9                          Element          0..unbounded
         N901                          Element     xsd:string     0..1
    Group_ZA                        Element          0..unbounded
         D02_ZA                          Element          0..unbounded
            ZA01                          Element     xsd:string     0..1
            ZA_Y2K_D                        Element     xsd:date     0..1
    S01_CTT                          Element          0..unbounded
    CTT01                          Element     xsd:integer     0..1
    Target Structure:
    p1:ProductActivityNotification     Element     
    MessageHeader                          Element     1
    ProductActivity                          Element     1
    ValidityPeriod                          Element     0..1
    SubcontractingIndicator           Element         0..1
    BuyerParty                                                Element     0..1
    VendorParty                                                Element     0..1
    ProductRecipientParty                           Element     0..1
    InboundDeliveryReference     Element     0..unbounded
    Item                                                Element     1..unbounded
    Item                                                Element     1..unbounded
    PromotionSalesTimeSeries                           Element     0..1
           Item                                                Element     1..unbounded
               ValidityPeriod                           Element     1
                    Quantity                           Element     1
    If ZA01 = 'QS' we need to produce target node "PromotionSalesTimeSeries" else shouldn't.

  • How to get Parent Symbol name of current e.target element ?

    How can I get the Parent Symbol name of the current e.target element ?
    would that involve using this ?
    getParentSymbol()
    Thanks for the help

    Hi ,
    I created a composition where I am trying to access the parent symbol of a rectangle. The structure is like this -
    Stage->parentMainSymbol->ChildSymbol->childRectangle. Now for the parentMainSymbol click , to access the rectangle element(which is the target) you can use the following snippet -
    sym.getComposition().getStage().getSymbol("parentMainSymbol").getSymbol("ChildSymbol").$(" childRectangle")
    Now, the parent of this is ChildSymbol whose reference could be obtained by -
    sym.getComposition().getStage().getSymbol("parentMainSymbol").getSymbol("ChildSymbol").$(" childRectangle")[0].offsetParent
    The info about the parent symbol is just being printed in the console view for the attached composition. This would print it out for -
    #Stage_parentMainSymbol_childSymbol which is the parent symbol of the target childRectangle under consideration.
    Kindly, take a look and let me know if it solves your problem.
    Thanks and Regards,
    Sudeshna Sarkar

  • How did i solve "Cannot create target element" but still having problems.

    Hi Experts,
    I solved my problem of "Cannot create target element" by removing of the data type structure the following fields :
    DT_AS400_1 -> Complex Type
    Payroll      1..1   (Should i put 0..0?)
       ->  Row  0..Unbounded And then Fields to be passed.
    I can't figure how pi can't detect the fields, i use them pretty often.
    Any Suggestions,
    Thanks for your help,
    Regards,
    Steve.

    Hi Steve,
    Check if input message, has the field that is producing the output.
    Therefore, if you don't have any input to fill the structure root, you can fill it with an empty constant.
    Best regards,
    Pedro M. D. Pereira
    Edited by: Pedro Pereira on Jun 10, 2010 1:26 AM

  • How OSB handling null element?

    hi Guys,
    I having question about how to handling a null node during trasnfortation and mapping using oracle workshop for OSB 10g.
    Well i have a consumer that not sending the element into the proxy, so during the proxy i will need to transform it into null element to the provider. what's in my mind is transform the element tag into something like this
    { if (fn:nilled($getAssetAttribReqParam1/RequestHdr/ns1:RequestId)) then
    <ns1:RequestId xsi:null = "true"/>
    else
    (<ns1:RequestId>{ data($getAssetAttribReqParam1/RequestHdr/ns1:RequestId) }</ns1:RequestId>)
    but when i doing testing it still showing this
    <ns1:RequestId></ns1:RequestId>
    i will need to sent the element something like this to the provider. because if this element is date format it will fail in the validation if i sending *<ns1:RequestId></ns1:RequestId>*
    <ns1:RequestId xsi:null = "true"/>

    I think your case should be addressed like -
    if ($getAssetAttribReqParam1/RequestHdr/ns1:RequestId) then
    <ns1:RequestId>{ fn:data($getAssetAttribReqParam1/RequestHdr/ns1:RequestId) }</ns1:RequestId>
    else
    <ns1:RequestId/>
    Regards,
    Anuj

  • XSLT mapping, how can I include a Runtime Constants in target message

    Hi, I would like in my XSLT mapping, to have an attribute include the MessageID.
    From my understanding of the online help [http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm|http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm], I have the following code in my XSL:
                   <xsl:param name="MessageId" />
                   <xsl:attribute name="filename">Output_<xsl:value-of select="$MessageId"/>.xml</xsl:attribute>
    But for now the result is to have a filename attribute that only contains: "Output_.xml" as if the $MessageId is empty.
    Anyone experienced successfully using one of those runtime constants with XSLT mapping ?
    Cheers,
    greg

    Hi, found the answer of why it was not running: I'm in a transform step of a BPM:
    For more info check this thread:
    [/message/435521#435521 [original link is broken]|/message/435521#435521 [original link is broken]]

Maybe you are looking for

  • Can I "lift" my install and put on a clean drive?

    Over the past few years, my system (specifically my sda)  has become cluttered and sda has been broken into more partitions than I need or want. When I installed Arch, it was more an experiment than anything else. I had 2 other distros on sda then. I

  • Count number of characters in a string

    Another one for you experts: Is there a way to count the number of "-" in the strings below: For instance: 1133500-1-RTN-629-RHR 1133541-10-SRTN-F-630-LR Should return: 4 5 respectively. Any ideas? Thanks in advance, Zack H.

  • Always lower case web-inf when WARing

    The strangest thing happens when I try to create a WAR for deployment. First let me start off by saying I have never had to deploy on a windows box before and I am wondering if this is a Windows (2K) problem. I am trying to use "jar cvf app.war ." fr

  • System information shows free space as taken up by apps

    Hey all, I don't have any issues with the functionality of the drive, only that the free space shows up as used by apps. Any ideas why this could happen? If it's an app causing this I can let it go. Or is it 'System Information' who's misbehaving? Tr

  • Nast protocol updation error

    Hi Folks, It is quite explanatory why I am posting this question. I am trying to update a nast protocol in my driver program and I am popualting the nast table using nast_protocol_update in sales Invoicing. The problem is that expect issuing printing