XML leading trailing space in elements removal.

Hi,
I am getting an xml file like this.
<House>
<Refrigirator> Whirlpool </Refrigirator>
<WashingMachine> Samsung</WashingMachine>
<TV> Samsun TV </TV>
<cooler> L G </cooler>
</House>
I have to get the output with out trailing spaces in the XMl elements. No schema restrictions has to be applied on this xml file only either with XSLT/Xquery or any other which suits to this I have to use.
<House>
<Refrigirator>Whirlpool</Refrigirator>
<WashingMachine>Samsung</WashingMachine>
<TV>Samsun TV</TV>
<cooler>L G</cooler>
</House>
Thanks.
Edited by: user12679330 on Jul 13, 2011 12:41 AM

input xml is not enough to correct me
* <Washing Machine> -> <Washing_Machine>
* space in xmlelement
better to change the procedure of forming xml
but in you case
try something
with T as
(select xmltype(
'<House>
<Refrigirator> Whirlpool </Refrigirator>
<Washing_Machine> Samsung</Washing_Machine>
<TV> Samsun TV </TV>
<cooler> L G </cooler>
</House>') xml from dual)
select replace(replace(xml,'> ','>'),' <','<') from t
REPLACE(REPLACE(XML,'>','>'),'<','<')                    
<House>
<Refrigirator>Whirlpool</Refrigirator>
<Washing_Machine>Samsung</Washing_Machine>
<TV>Samsun TV</TV>
<cooler>L G</cooler>
</House>                                                                                                                                                                           

Similar Messages

  • Requesting for your kind help...(want to preserve Leading & trailing spaces)

    Hello Team,<br /><br />Can you please help in the following issue:<br />I am trying to preserve white space(leading and trailing  L&T) as is on the User Interface.  We have built our UI using Flex 3.0 SDK. <br /><br />From Java side, I am able to carry the value with L&T spaces till the call goes to Flex .mxml and here response object assigning as  <br /><br /> var metaConfig:XML = event.result as XML;<br />But here L&T spaces are not visible along with value of ID.<br />I used to see it by using Alert.show(event.result.toString());<br /> <br />Flex Output is as:<br /><br />       <allScalarMetadataFields><br />      <id>TEST</id><br />      <name>test name</name> <br />.<br /><br />But from java[in Servlet/in service] side I can see the output as:<br /><br />   <allScalarMetadataFields><br />       <id>   TEST  </id><br />       <name>   test name    </name><br />.<br /><br />Java(Servlet) code is as follows:<br />      OutputStream writer = response.getOutputStream();<br />      OutputStreamWriter outputStreamWriter = new OutputStreamWriter(writer,"UTF-8");<br />JAXBContext context = JAXBContext.newInstance(object.getClass(), object.getClass());<br />         Marshaller m = context.createMarshaller();<br />         m.marshal(object, writer);<br />.Here marshal follow a standard structure for XML to map  it into writer same as what Flex XML follows.....<br /><br />Note, there is no any other issue/fault  with Flex and java except this white spaces.<br /> <br />Flex .mxml code is as:<br /><br />protected var _fieldXml:XML;<br />      public function MetadataFieldWrapper(xml:XML = null)<br />            {<br />                  if (xml == null)<br />                  {<br />       xml = <allScalarMetadataFields xml:space="preserve"><br />               <id /><br />                <name /><br /><br />...<br /><br /> Servlet is getting called as :<br /><br />            _webService = new HTTPService();<br />                  _webService.url = serviceUrl;<br />                  _webService.method = "POST";<br />                  _webService.resultFormat = "e4x";<br />                  _webService.contentType = "application/xml";<br /><br />.<br />_webService.headers = { "serviceName":serviceName, "serviceMethod":serviceMethod };<br />                  _webService.send(param);<br /><br />I want to preserve the L&T spaces along with ID/name .<br />Please help me how to allow these L& T spaces in Flex XML object?<br /><br /> <br />Thanks in Advance.<br />Regards,<br />Venu.

    In the future this type of question should be asked on flexcoders as<br />it doesn't relate to the development of the Flex SDK.<br /><br />To preserve whitespace look at the documentation for XML.ignoreWhitespace.<br /><br />-- Daniel R. <[email protected]> [http://danielr.neophi.com/]<br /><br />On Wed, Nov 12, 2008 at 8:19 AM, venubwal <[email protected]> wrote:<br />> A new discussion was started by venubwal in<br />><br />> Developers --<br />>   Requesting for your kind help...(want to preserve Leading & trailing<br />> spaces)<br />><br />> Hello Team,<br />><br />> Can you please help in the following issue:<br />> I am trying to preserve white space(leading and trailing  L&T) as is on the<br />> User Interface. We have built our UI using Flex 3.0 SDK.<br />><br />> From Java side, I am able to carry the value with L&T spaces till the call<br />> goes to Flex .mxml and here response object assigning as

  • SAP DME Nodes - Can we have leading/trailing spaces?

    Hi All,
    I have a requirement to populate a DME node from a REGUP value by offsetting that accordingly.
    As an example: I used 1 Exit-Module where I wrote like:
    C_VALUE = REGUP-<FIELD>+0(10).      " The node is defined in tree as 10 Characters.
    It must work properly. But I found, if REGUP-<FIELD> returns a value like '12345ABCD EFGH' [Mind the 10th position is a space] then the NODE is showing 12345ABCD only and just after immediate 9th position a COMA is coming as I am using COMA delimiter. So, an extra space shoud be there after the D which is missing.
    In one word, the Trailing spaces are not coming and same is happening for Leading spaces as well. In between spaces are coming fine.
    Can anybody please help me to have that Leading and Trailing spaces in DME output file?
    I could not found any suitable 'Conversion Function' for that node. Is there anything?
    Can we write custom 'Conversion Function'? Or any Exit/BAdI to manipulate the output?
    -Thanks, Arghya

    After consulting other ADF experts offline, we have come to conclusion that there is no off-the shelf component which caters to my requirement.
    We are now going with complete custom solution to achieve shuttle behavior.
    I am marking this query as answered.
    Thanks,
    Sandeep

  • External material number with trailing spaces

    Hi ,
    One of our users created a material number(external number range) by copying it  from a spreadsheet. The value he copied had trailing spaces and when he copied it on to material number field the trailing spaces were not removed by SAP conversion routines . But when we deliberately type in trailing spaces the system removes them. Has anyone faced this kind of problems before? If so what is the solution.
    Thanks,
    Veera

    Any Input??????

  • Trailing spaces in env-entry-type elements

    Hi,
    We have been porting our EJB application from another app server over to Oracle iAS (9.0.3 Lite) and have encountered a rather frustrating problem.
    We have an CMP (2.x) entity bean that has ejbSelect methods. There are corresponding <query> blocks in the ejb-jar.xml file for these methods. In the same ejb-jar.xml file there are <env-entry> blocks that setup a few things that are needed by the bean.
    If the <env-entry-type> element is written as "<env-entry-type>java.lang.String </env-entry-type>" (note the trailing space after the type name) the following exception occurs during deployment of the ear file;
    java.lang.InstantiationException: Failure to initialize EJBQL descriptors: com.sun.enterprise.deployment.xml.ContentTransformationException: java.lang.String is not an allowed property value type
         at com.evermind.server.ejb.deployment.EJBPackage.initializeEjbqlDescriptors(EJBPackage.java:2075)
         at com.evermind.server.ejb.deployment.EJBPackage.init(EJBPackage.java:2054)
         at com.evermind.server.ServerComponent.init(ServerComponent.java:208)
         at com.evermind.server.ejb.EJBPackageDeployment.getPackage(EJBPackageDeployment.java:672)
         at com.evermind.server.administration.ServerApplicationInstallation.finish(ServerApplicationInstallation.java:547)
         at com.evermind.server.administration.ServerApplicationInstallation.deploy(ServerApplicationInstallation.java:913)
         at com.evermind.server.administration.DefaultApplicationServerAdministrator.deploy(DefaultApplicationServerAdministrator.java:337)
         at java.lang.reflect.Method.invoke(Native Method)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:119)
         at com.evermind.server.rmi.RMICallHandler.run(RMICallHandler.java:48)
         at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
         at java.lang.Thread.run(Thread.java:479)
    Error during deployment: Failure to initialize EJBQL descriptors: com.sun.enterprise.deployment.xml.ContentTransformationException: java.lang.String is not an allowed property value type
    Removing the trailing space and the deployment proceeds to completion without exceptions.
    I should also add that if the ejbSelect methods are remove d from the application and the trailing space left in place the resulting ear file will deploy sucessfully.
    It is trivial to reproduce this problem with the ORMAP demo that ships with 9.0.3.
    This was a really subtle problem that is not present on the *3* other appserver implementations that our application runs on. It was very frustrating to locate and perhaps some consideration could be given to how PCDATA is handled when parsing <env-entry-type> blocks.
    Cheers,
    Mick.

    Hi ,
    Create two Characteristic InfoObjects in BW With length 60 Char  and then in the Transfer Rules of this two InfoObjects write the Formula using Left() and right() function present in the Formula Builder .
    That is First infoObject Contains the Left 60 Char and next one Contains the right 60 Char.
    Regards,
    Vijay.

  • File Content Conversion Removes Leading Blank/Space

    I'm having a problem where file content conversion is trimming leading blanks/space/whitespace from fields when reading in the inbound file.  I've seen where people have posted that you need to use fieldContentFormatting to prevent content conversion from stripping the leading/trailing whitespace.  I added that parameter to my list (see below example) but it still appears to be trimming the leading whitespace.  Look forward to hearing your thoughts.  Here are the details:
    I'm using fixed length file content conversion for Sender File Adapter (SP15).  I have the following parameters set:
    Document Name = MaterialData
    Recordset name = item
    Recordset Structure = MaterialLine, 1
    I have:
    MaterialLine.fieldNames = matno_external, mat_description
    MaterialLine.fieldFixedLengths = 40, 40
    MaterialLine.fieldContentFormatting = nothing, nothing
    The following is the input file (notice spaces prior to second occurrence of material numbers)
    ZED00000001                             AIMS LIGHT A
    ZED00000001                            AIMS LIGHT B
    ZED00000002                             AIMS SWITCH A
    ZED00000002                            AIMS SWITCH B
    ZED00000003                             AIMS SEMICONDUCTOR A
    ZED00000003                            AIMS SEMICONDUCTOR B
    The following is the source XML after file content conversion from SXMB_MONI (note spaces no longer exist in matno_external tag).
    <?xml version="1.0" encoding="utf-8" ?>
    - <ns:MaterialData xmlns:ns="http://xxxxxxx.com/yyy/test">
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000001</matno_external>
      <mat_description>AIMS LIGHT A</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000001</matno_external>
      <create_date>10/09/06</create_date>
      <mat_description>AIMS LIGHT B</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000002</matno_external>
      <mat_description>AIMS SWITCH A</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000002</matno_external>
      <mat_description>AIMS SWITCH B</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000003</matno_external>
      <mat_description>AIMS SEMICONDUCTOR A</mat_description>
      </MaterialLine>
      </item>
    - <item>
    - <MaterialLine>
      <matno_external>ZED00000003</matno_external>
      <mat_description>AIMS SEMICONDUCTOR B</mat_description>
      </MaterialLine>
      </item>
      </ns:MaterialData>

    Thanks all for your attempts but I figured it out and wasn't this the biggest case of irony.
    Here I was trying to prevent leading spaces from being trimmed in the loading of my file and my problem was that when I typed:
    MaterialLine.fieldContentFormatting
    I actually left a "blank" at the end of the "g" in Formatting.  Apparently XI didn't like that and neither gave me a runtime or compile error.  Anyway I found this and though I'd share in case anyone else encounters it.  I removed the blank and all is working now.

  • How to remove trailing space-sqlldr failed OCI-30951-exceeds max length

    sqlldr failed to load the xml into xdb ( table created through schema registration) because of the padded space in element 'Country' whose maximum length is defined as '3'…Is there any way to remove the extra trailing space using the control file or xdb annotation in the xsd? Thanks!
    <Address>
    <StreetAddress1>1 BRKSTONE SQ </StreetAddress1>
    <StreetAddress2>SUITE 5 </StreetAddress2>
    <City>ANDOVER </City>
    <State>MA</State>
    <Country>USA </Country>
    <ZipCode>01810</ZipCode>
    </Address>
    Here is the errors I got:
    kgepop: no error frame to pop to for error 30951
    OCI-30951: Element or attribute at Xpath /BranchRegulatoryFiling/Branches/Branch[1]/Address/Country exceeds maximum length
    Errors in file :
    OCI-30951: Element or attribute at Xpath /BranchRegulatoryFiling/Branches/Branch[1]/Address/Country exceeds maximum length
    ----- Call Stack Trace -----
    Bus Error (core dumped)
    Here is my ctl file:
    load data
    infile *
    into table xml_stg_tbl
    append
    reenable disabled_constraints exceptions cnstr_xcptn_tbl
    xmltype(XMLDATA)(
    lobfn filler char terminated by ',',
    XMLDATA lobfile(lobfn) terminated by EOF
    BEGINDATA
    /tmp/1025552.xml
    Edited by: user10954036 on Jul 27, 2009 8:12 AM

    Hi,
    Its good that u pasted the complete log file. In your environment you have to run this upgrade tool only once from any of the middle tier.
    And with respect to your error that u got in precheck is quite simple. All u have to do is just run this script from by connecting to portal schema using sqlplus.
    Run dropupg.sql
    Location-------- /raid/product/OraHome_1/upgrade/temp/portal/prechktmp/dropupg.sql
    Later you re-run the upgrade tool and let me know the status.
    Good luck
    Tanmai

  • Warning Leading or trailing spaces ?

    Hello,
    I have a warning mesg : Presentation column has leading or trailing spaces in it
    What does it mean ?
    Thanks

    hi user,
    Rename the column ....u have some extra space before/after the column remove that
    u can refer this : http://www.obinotes.com/2010/09/leading-or-trailing-spaces-in.html
    thanks,
    Saichand.v

  • Export to text removes trailing spaces in XI R2

    I've found an article that talks about the problem of the export to text removing trailing spaces, but the article mentions that this is fixed in Crystal Reports XI with a newer version of u2ftext.dll to version 11.0.0.941.
    [1218375 - Trailing spaces ignored when exporting to Text format|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313338333333373335%7D.do]
    I'm using Crystal Reports XI R2 and my u2ftext.dll version is already 11.5.11.1470.
    I'm I missing something or is there another solution to the issue in XI R2?
    Thanks,
    Jeff

    2 Years, multiple people are asking this question.......Does anyone in support have a response for keeping the trailing spaces intact during export?

  • Report Painter Report - Leading White Spaces in Cost Element

    When calling up a report painter report, e.g. S_ALR_87013613, with cost element characteristic in Office integration/Microsoft Excel as output parameters, the cost element (row item) is indented with white spaces.  The number of white spaces seems to be in relation with summation levels (sub-totals) visible in the left panel.  For some cost centres that only have limited transactions, such as no posting to salary account group, there are less levels of summation, meaning less leading white space in cost elements.  Is there any way to eliminate or have a fixed number of leading white spaces in cost elements? 
    We export the report to Excel worksheet for further processing.  VLOOKUP function is used to read the cost element into another workbook.  The inconsistent number of leading white spaces creates a problem for the formulas to work properly. 
    Any suggestion is appreciated.
    Regards,

    Hello,
    There are different ways of downloading the report to excel. One option is
    System ==> List ==> save (to local file)
    Please try with other options.
    If still not working, then the work around would be
    You can put ctrl+H (replace all spaces)
    Then text to columns
    Hope this works.
    Regards,
    Ravi

  • Removing leading zeros and leading blank spaces from an input field

    Hi All,
    I have an input field which is alphanumeric and i need to remove the leading zeros and blank spaces in it , but intermediate spaces should be kept .
    so i used the UDF
            String output = input.replaceFirst("^0+","");
            return output;
    but this code does not remove the leading blank spaces . Can anybody help in modifying this code so that even the leading blank spaces along with leading zeros  can be removed .
    Regards ,
    Loveena .

    lets say input is a
    then
    int len = a.length();
    for(int i;i< length;i++)
    if(a.substring(0,1).equals(" ") || a.substring(0,1).equals("0"))
    a = a.substring(1,len);
    return a;
    hope you got the logic so that you can enhance it better

  • Regular Expression To Remove Leading While Space

    Hii
    I have a data like this
    20200 Kuala Terengganu
    Terengganu
    Luala Terengganu
    I want to remove the Leading white space in the Second line .Can anybody help me to
    write regular expression for this?
    I want my result like the following :
    20200 Kuala Terengganu
    Terengganu
    Luala Terengganu
    Thanks In Advance
    Jim John

    But there's no difference between two group of lines which you posted. Could you please format your input and desired output with please?
    Kamran Agayev A. (10g OCP)
    http://kamranagayev.wordpress.com                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to remove trailing spaces in SQL PLUS spool

    Hi,
    I've requirement to pull data from tables and I'm using sqlplus spool to automate data fetch from various tables:
    I'm using the following script for the same :
    set echo off
    set feedback off
    set pagesize 0
    set linesize 2000
    set heading on
    set trimspool on
    Spool table1.TXT;
    prompt col1|col2|col3|col4|col5
    select
    LTRIM(RTRIM(col1))||'|'||
    LTRIM(RTRIM(col2)) ||'|'||
    LTRIM(RTRIM(col3)) ||'|'||
    LTRIM(RTRIM(col4)) ||'|'||
    LTRIM(RTRIM(col5)) ||'|'||
    from TABLE1 ;
    spool off
    After using trimspool on option also I'm having trailing spaces issue how to fix it?
    Thanks,
    Mahender.
    Edited by: user518071 on Oct 11, 2010 1:05 PM

    Hi,
    do you need LTRIM/RTRIM? This is namely your problem. By using a function around your column Oracle reserves the maximum lenght for the column. So what do you get without those functions? Furthermore you are concatenating all the columns. This is also a function. For getting '|' in between columns you can also set a seperator by using
    set colsep '|'Herald ten Dam
    http://htendam.wordpress.com

  • Addition of Trailing space resulting in zeros

    I am adding trailing space to MATNR after removing the leading zeros. I am adding hex value of space 0x20, however instead of spaces , zeroes are being added to the end of the field. What could be the reason? Is there any other method of adding trailing space.
    My Code
    loop at i_output.
        CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
          EXPORTING
            INPUT  = i_output-matnr
          IMPORTING
            OUTPUT = i_OUTPUT-matnr.
        l_pos = strlen( i_OUTPUT-matnr ).
        numtimes = 15 - l_pos.
        do numtimes times. " add trailing spaces
          i_output-matnr+l_pos(1) = c_space.
          l_pos = l_pos + 1.
        enddo.

    Here you go...
    loop at i_output.
    concatenate i_output-matnr
                   i_output-werks
                   i_recty
                   runweek
                   cmenge "i_output-menge
                   i_output-qsign
                   i_output-numdocs into out_rec.
        istrlen = strlen( out_rec ).
        transfer out_rec to ofilepath length istrlen.
        clear out_rec.
      endloop.
    I am using ECC5.0
    Edited by: sanjane on Feb 25, 2010 8:51 AM

  • XI 3.0: Preserve trailer spaces with JMS Adapter

    Hi everybody
    Does anybody knows how it is possible to preserve the trailing spaces in a message coming from JMS adapter?
    I have a fixed-length field that is filled with a left space trailer, but the space is removed by (i think) the adapter.
    Does exists something similar to "whitespace=preserve" for the datatypes???
    Thanks in advance.

    If somebody is interested, just add the
    xml.<structname>.fieldContentFormatting = nothing to the module configuration params.
    I derived this one from the configuration guide of the File Adapter

Maybe you are looking for