WhiteSpace in XML

I created xml file from database and i have whitespace inside of element node: eg
<id>12 </id>
how can i eliminate whitespace when i use xslt on it.. i'm trying this:
<xsl:value-of select="/results/record[id=12]"/>
but it doesnt give me anything.. because i have whitespace inside of id element.. help me please
-Sumit

Use one of the XPath string functions. I don't have my reference book here but the one you want is called something like normalize-text, so look it up in your reference. Your element would then look something like this:
<xsl:value-of select="/results/record[normalize-text(id)=12]"/>

Similar Messages

  • Whitespaces in XML during message mapping not preserved

    I use a twostep mapping process during Interface Mapping. The first one is the standard message mapping and the second one is a Java mapping. However, during the second step, the white spaces that should be preserved from the output of the first mapping is not there anymore. I created the XSD and specified in the details that the white spaces should be preserved.
    I need the whitespaces since the output of the second mapping would be used for file content conversion in a file adapter to create the output:
    MSGTYP CONTROLNOMSGID VALUE1VALUE2 VALUEn.....
    Is there any way to preserve the white spaces?
    Thanks!
    Best Regards,
    Rommel Mendoza

    This is odd. Java won't condense/trim the whitespaces unless explicitely told so.
    Where are you seeing the missing whitespaces?
    Please notice that SXMB_MONI won't show the spaces because it uses a HTML representation of the XML (and, by default, HTML condenses the whitespaces). But the actual XML file should have all the spaces (check the XML document source code, through mouse right click over payload, to be sure).
    Also, what are the conversions you do in the java mapping?
    Are you sure the java mapping input has the whitespaces?
    Regards,
    Henrique.

  • Preserve whitespace in xml parsing

    Hi,
    I am using PL.SQL to parse XML documents using DBMS_XMLDOM..
    and using XMLTYPE...
    Below is the code...
    set serveroutput on
    declare
         var_xmltype     XMLType;
         doc          dbms_xmldom.DOMDocument;
         ndoc          dbms_xmldom.DOMNode;
         docelem          dbms_xmldom.DOMElement;
         node          dbms_xmldom.DOMNode;
         l_loop_group_8_node_list          dbms_xmldom.DOMNodelist;
         l_loop_group_8_node_list_count          number(10);
         l_loop_group_8_sub_node_list          dbms_xmldom.DOMNodelist;
         l_lin_segment_node          dbms_xmldom.DOMNode;
         l_lin_segment_child_node     dbms_xmldom.DOMNode;
         l_loop_group_8_count number(10);
         p_clob_message CLOB;
         l_clob_message CLOB;
         CURSOR c is SELECT * from emx_message_storage where emx_message_id = '170615';
    begin
    for r in c loop
    p_clob_message := r.message_clob;
    end loop;
         var_xmltype := xmltype (p_clob_message);
         -- Create DOMDocument handle
         doc :=     dbms_xmldom.newDOMDocument (var_xmltype);
         ndoc := dbms_xmldom.makeNode (doc);
         docelem := dbms_xmldom.getDocumentElement (doc);
         -- Access Loop-Group_8 Node:
         l_loop_group_8_node_list := dbms_xmldom.getElementsByTagName(docelem, 'Loop-Group_8');
         l_loop_group_8_node_list_count := dbms_xmldom.getlength (l_loop_group_8_node_list);
         --dbms_output.put_line ('Number of Loop-Group_8 Nodes =' || l_loop_group_8_node_list_count);
         FOR l_ka IN 0..(l_loop_group_8_node_list_count-1) LOOP
              -- Get ith Loop-Group_8 node.
              node := dbms_xmldom.item (l_loop_group_8_node_list, l_ka);
              l_loop_group_8_sub_node_list := dbms_xmldom.getChildNodes (node);
              -- Get Segment-LIN
              l_lin_segment_node := dbms_xmldom.item (l_loop_group_8_sub_node_list,0);
              l_lin_segment_child_node := dbms_xmldom.getFirstChild (l_lin_segment_node);
              --dbms_output.put_line ('Before,' || dbms_xmldom.getNodeName (l_lin_segment_child_node) || ' = '  || dbms_xmldom.getNodeValue (DBMS_XMLDOM.getFirstChild(l_lin_segment_child_node)));
              dbms_xmldom.setNodeValue (DBMS_XMLDOM.getFirstChild(l_lin_segment_child_node), l_ka+1);
              --dbms_output.put_line ('After,' || dbms_xmldom.getNodeName (l_lin_segment_child_node) || ' = '  || dbms_xmldom.getNodeValue (DBMS_XMLDOM.getFirstChild(l_lin_segment_child_node)));
         END LOOP;
         DBMS_LOB.CreateTemporary(l_clob_message, TRUE);
         dbms_xmldom.writeToClob (doc, l_clob_message);
         dbms_xmldom.freeDocument(doc);
         update emx_message_storage set message_clob = l_clob_message where emx_message_id = '149329';
    end;
    The code works fine.. except for the fact that when in the input XML message i get one element as
    <Element-3042> </Element-3042>
    it converts it to
    <Element-3042/>
    The whitespace is removed...
    I tried using the xml parser method...and whitespacepreserver optioin...but it creates some extra lines...
    Which i dont want.
    Please suggest.
    Thanks,
    Rosh

    Difficult to read non-formatted code, so pardon not looking at it and trying to spot the problem/error. However, whitespaces seem to work fine for me (tested on 10.2.0.4). Note the resulting XML for a string value, a whitespace value and a null.
    SQL> create table foo_tab( attr1 number, attr2 varchar2(10) );
    Table created.
    SQL>
    SQL> insert into foo_tab values( 1, 'test 123' );
    1 row created.
    SQL> insert into foo_tab values( 2, ' ' );
    1 row created.
    SQL> insert into foo_tab values( 3, null );
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> col XML format a50
    SQL> select
      2          XmlElement( "Row",
      3                  XmlForest(
      4                          attr1 as "Name",
      5                          attr2 as "Value"
      6                  )
      7          )               as XML
      8  from       foo_tab
      9  /
    XML
    <Row><Name>1</Name><Value>test 123</Value></Row>
    <Row><Name>2</Name><Value> </Value></Row>
    <Row><Name>3</Name></Row>
    SQL>

  • Preserve paragraph whitespace in XML Data

    I'm having problems using the Spry Gallery. I've added a new
    tag called <artistbio>, which contains paragraphs. How do I
    get line breaks or whitespace to be preserved. Using HTML tags
    doesn't appear to work.
    I'm sure it's something simple, but this is my first venture
    into XML.
    example:
    http://www.gracepointe.net/gallery/
    an xml file with whitespace:
    http://www.gracepointe.net/gallery/r_baldwin.xml
    thanks!
    clint

    Marco,
    Thanks for your reply.
    Well, I am not building a SOAP Envelope for posting the data to the service.
    I am using a plain XML here, so I used REPLACE(<XML Data>,' ','%20') which solved my issue.
    If you think my solution might have some side effects then please suggest me.
    Thanks,
    Raj.

  • Preserving whitespace in XML fields?

    I have a requirement to preserve the character positioning within an XML field. I am using the standard XML/HTTP port for output from the ALE interface. One of the fields contains multiple spaces within the data. It appears the default setting of the XML processor is to condense these spaces into a single space. The xsl:preserve-space pre-processor command should preserve the whitespace, Does anyone know how to configure the SAP XML processor to do this?   Thanks!
    We are using basis 6.20

    There's a setting in Flash's XML object called ignoreWhitespace that you need to set to false (by default its true).
    Something like this should work:
    function convertStringToXML(source:String):XML
         var originalSettings:Object = XML.settings();
         try
              XML.ignoreWhitespace = false;
              var xmlTree:XML = new XML(source);
         finally
              XML.setSettings(originalSettings);
         return xmlTree;
    - robin

  • Whitespace in XML-Style JSP

    Hi,
    I am having a slight issue with the XHTML content generated by a JSP. The output is stripped entirely of all whitespace, such that the content is all on one line. I have a request from one of our content writers to view the source "nicely". Oddly, in all of my searches for this problem, I have found people experiencing the opposite problem.
    Suppose I have a JSP like so:
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
    <jsp:directive.page language="java" contentType="text/html;charset=ISO-8859-1"/>
    <html>
    <head>
         <title>A JSP Page</title>
    </head>
    <body>
         <table>
              <tr>
                   <td>Table Cell</td>
              </tr>
         </table>
    </body>
    </html>
    </jsp:root>The resulting output is:
    <html><head><title>A JSP Page</title></head><body><table><tr><td>Table Cell</td></tr></table></body></html>How can I get the output to have the same indentation as the source?
    I am using Tomcat 4.1.29.
    Thanks!

    Hi Syed,
    Try these links:
    <a href="http://www.javaranch.com/newsletter/Feb2002/xmljsp.html">Exploring JSP Documents (XML Style JSP Pages)</a> --> an excellent overview of the benefits of JSP Documents (XML Style JSPs) over standard JSP Pages.
    <a href="http://www.webmonkey.com/webmonkey/01/22/index3a.html?tw=programming">Intro to JSP</a>
    You can also try googling for "XML Style JSP"...
    Regarding books on JSP 2.1 and Servlet 2.5 -- I really can't believe that there are none available! Have you tried searching on amazon?
    HTH!
    -Vladimir

  • Whitespace in XML blows up my code

    I know this points to bad code. Here's my question. First of all I have to run java 1.3.xx for this project. I've created a web service returning data to the client. The client is using:
    javax.xml.parsers.DocumentBuilder;
    javax.xml.parsers.DocumentBuilderFactory;
    to build the document. Also I had to import
    org.w3c.dom
    so I assume that's the implementation. As the data is in a proprietary format I used the following to get the nodes and values I wanted:
        for(int a = 0; a < tmp.getChildNodes().getLength(); a++)
          Node type = null;
          Node name = null;
          if(tmp.getChildNodes().item(a).getChildNodes().item(0).getNodeName().equals("FieldName"))
            name = tmp.getChildNodes().item(a).getChildNodes().item(0);
          if(tmp.getChildNodes().item(a).getChildNodes().item(1).getNodeName().equals("FieldName"))
            name = tmp.getChildNodes().item(a).getChildNodes().item(1);etc etc. All was fine until I changed my web service to return a more human readable format a la
    <mainNode>
      <childNode>value</childNode>
      <childNode>value</childNode>
    </mainNode>  I added the new lines and the indenting. I get null pointers from the Document parsing. So, I guess the whitespace breaks things. Is there a better parser I should be using? Do all parsers have idiosyncracies like this? Should I be doing some type of formatting the data prior to parsing?
    Thanks
    ST

    Dr., I'm glad to see that you're still posting here. I've been away for a while.
    I'm curious and confused. Consider the following:
    ex 1:
    <elementA>
      <elementB>value</elementB>
      <elementB>value</elementB>
    </elementA>
    ex 2:
    <elementA><elementB>value</elementB><elementB>value</elementB></elementA>Aren't both examples syntactically the same? This is the difference that I am seeing. The second example works with my code, the first does not.
    Thank you for your thoughts.
    ST

  • Whitespace in xml result from SQL Utility

    We're currently using the XML SQL Utility (ver XSU12, 8.1.7 database) with PL/SQL. We're able to successfully retrieve XML based result from the database.
    However, almost a fourth of the document that's returned from the utility in CLOB is whitespace, which is not necessary in our application. Is there any way we can suppress this whitespace, so that the resulting document trasferred over the network is kept the smallest possible.
    Thanks in advance
    Murthy Jarugumilli

    Use one of the XPath string functions. I don't have my reference book here but the one you want is called something like normalize-text, so look it up in your reference. Your element would then look something like this:
    <xsl:value-of select="/results/record[normalize-text(id)=12]"/>

  • How to prohibit leading and traling whitespace in XML Schema

    I want to prohibit the use of leading and trailing whitespace in an element but besides that all other content is allowed.
    For examble <   word? > should give a validation error.
    I do not want to use
    <whiteSpace value="collapse"/>
    Because it doesn't give a validation error.
    Is it possible to make a pattern og in some other way solve my problem?
    Thanks in advance, Martin

    Here is an example schema snippet (not a complete schema!) that does what you want I think, using a regular expresssion pattern, allowing one or more non-white-space characters followed by an optional sequence of any character followed by one or more non-white-space characters:
    Code Snippet
            <xs:element name="foo" maxOccurs="unbounded">
              <xs:simpleType>
                <xs:restriction base="xs:string">
                  <xs:pattern value="\S+(.*\S+)*"/>
                </xs:restriction>
              </xs:simpleType>
            </xs:element>
    Here are some example elements with valid contents:
    Code Snippet
      <foo>a</foo>
      <foo>a b</foo>
      <foo>a b c d e f g</foo>
    And here some elements with invalid contents that validation would catch:
    Code Snippet
      <foo> a</foo>
      <foo>a </foo>

  • Preserve whitespace in XML element value

    I am trying to add XML element with value prefix with white space:
      ex_doc->create_simple_element(
          name = 'VALUEPART1'
          value = '          BQ/XWKB-99-5-9999-2'
          parent = lo_ele_e1bpparex_bape_vbak ).
    But when the XML is create, the white space is removed! How can I preserve the white space???
    <VALUEPART1>BQ/XWKB-99-5-9999-2</VALUEPART1>
    What i want is:
    <VALUEPART1>          BQ/XWKB-99-5-9999-2</VALUEPART1>
    Appreciate for any help

    Hi,
    if you had been using XSLT instead, I would have said 'remove the strip-space element or alter it according to your needs'...
    Please provide what class you are using, else it's too generic..
    regards, Lukas

  • Whitespace in XML (BPEL)

    Hi
    We are currently running bpel against SAP. SAP often requires fields with the value of a space. However we are not able to preserve the spaces during the bpel processing. IE.
    <?xml version='1.0' encoding='windows-1252'?>
    <input xmlns="http://www.example.org">
    <Id>44</Id>
    <Name> </Name>
    </input>
    will result in
    <?xml version='1.0' encoding='windows-1252'?>
    <input xmlns="http://www.example.org">
    <Id>44</Id>
    <Name />
    </input>
    Does anyone have a hint ?
    Regards Alex Høffner
    [email protected]

    Hi Chris,
    Are you checking your payload in SXMB_MONI ?
    If so SXMB_MONI message window will not dispaly white spaces in the message window(though spaces will be present in the message). You can just save your paylod as XML and open with wordpad to view the exact contents of the message..
    Regards
    Anand

  • Reading an xml file in actionscript using flex3

    plzz tell me how to read an xml file in actionscript using flex3.......

    One possible option to parse an xml-file to a flex XML object:
    public function parseConXML(source:String):void
                    xmlLoader = new URLLoader();
                    xmlLoader.load(new URLRequest(source));
                      // Eventlistener: if URL loaded --> onLoadComplete function
                      xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
                public function xmlLoadComplete(evt:Event):void{               
                    var xml:XML = new XML();
                     // ignore comments in XML-File
                    XML.ignoreComments = true;  
                       //ignore whitespaces in XML-File
                     XML.ignoreWhitespace = true;
                    // XML-Objekt erstellen
                    xml = new XML(evt.target.data);
                   //AFTERWARDS use your xml as your wish

  • Reading an xml file in the web services java file

    I want to read some data in the webservices file.so i am writing my own xml file through which i want to read data.but i am not able to read xml file from web services file.also , i am not able to put xml file in the .ear file,as there is no such tag in servicegen script through which i can add xml file in the .ear file.
    i know in case of servlets,i will specify context-param attributes in web.xml,and i can access those in my servlet.can i do anything like this for webservices,and i am not using any servlets for web services.
    kindly tell any solution.

    One possible option to parse an xml-file to a flex XML object:
    public function parseConXML(source:String):void
                    xmlLoader = new URLLoader();
                    xmlLoader.load(new URLRequest(source));
                      // Eventlistener: if URL loaded --> onLoadComplete function
                      xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
                public function xmlLoadComplete(evt:Event):void{               
                    var xml:XML = new XML();
                     // ignore comments in XML-File
                    XML.ignoreComments = true;  
                       //ignore whitespaces in XML-File
                     XML.ignoreWhitespace = true;
                    // XML-Objekt erstellen
                    xml = new XML(evt.target.data);
                   //AFTERWARDS use your xml as your wish

  • How to remove white spaces from XML content using Coldfusion?

    Hi,
    Can anybody help me in removing white spaces in between the tags from the below XML content using coldfusion?
    XML content:
    <?xml version="1.0" encoding="UTF-8"?> <chart showdates="true" today="08/12/2009"> <phases> <phase color="CCFFCC" name="Funded"/> <phase color="CDCD67" name="Concept"/> <phase color="99CCFF" name="Feasibility"/> <phase color="0099FF" name="Development"/> <phase color="0099FF" name="Development"/> <phase color="CC99FF" name="Close-out"/> <phase color="909090" name="Sustaining"/> </phases><program name=""> <project enddate=" 30/03/2007 " id="43250" startdate=" 28/02/2006 "> <version enddate=" 30/03/2007 " number=" 1" startdate=" 28/02/2006 "> <phase color="CCFFCC" currentdate="23/03/2006" name="Project Start" plandate="28/02/2006" type="phase"/> <phase color="99CCFF" currentdate="04/04/2006" name="Feasibility Closure" plandate="31/05/2006" type="phase"/> <phase color="0099FF" currentdate="29/03/2007" name="Commercialization" plandate="30/12/2006" type="phase"/> <phase color="CC99FF" currentdate="30/03/2007" name="Project Closed" plandate="30/03/2007" type="phase"/> <phase color="909090" currentdate="" name="Obsolescence" plandate="" type="phase"/> </version> </project> </program> </chart>
    Output I am expecting is like below,
    <?xml version="1.0" encoding="UTF-8"?><chart showdates="true" today="08/12/2009"><phases><phase color="CCFFCC" name="Funded"/><phase color="CDCD67" name="Concept"/><phase color="99CCFF" name="Feasibility"/><phase color="0099FF" name="Development"/><phase color="0099FF" name="Development"/><phase color="CC99FF" name="Close-out"/><phase color="909090" name="Sustaining"/></phases><program name=""><project enddate=" 30/03/2007 " id="43250" startdate=" 28/02/2006 "><version enddate=" 30/03/2007 " number=" 1" startdate=" 28/02/2006 "><phase color="CCFFCC" currentdate="23/03/2006" name="Project Start" plandate="28/02/2006" type="phase"/><phase color="99CCFF" currentdate="04/04/2006" name="Feasibility Closure" plandate="31/05/2006" type="phase"/><phase color="0099FF" currentdate="29/03/2007" name="Commercialization" plandate="30/12/2006" type="phase"/><phase color="CC99FF" currentdate="30/03/2007" name="Project Closed" plandate="30/03/2007" type="phase"/><phase color="909090" currentdate="" name="Obsolescence" plandate="" type="phase"/></version> </project></program></chart>
    Thanks in advance,
    Regards,
    Manoz.

    Daverms,
    Thanks for the quick turn around..
    I have applied the solution what you suggested above (<cfprocessingdrirective suppresswhitespaces="yes"), still whitespaces are existing in my output.
    The output what I am getting is,
    (blue color part is my output & red color indicates whitespaces)
    <?xml version="1.0" encoding="UTF-8"?>
    <chart showdates="true" today="09/12/2009">
    <phases>
    <phase color="CCFFCC" name="Funded"/>
    <phase color="CDCD67" name="Concept"/>
    <phase color="99CCFF" name="Feasibility"/>
    <phase color="0099FF" name="Development"/>
    <phase color="0099FF" name="Development"/>
    <phase color="CC99FF" name="Close-out"/>
    <phase color="909090" name="Sustaining"/>
    </phases>
    <program name="">
    <project enddate=" 01/01/2010 " id="12059" startdate=" 20/06/2003 ">
    <version enddate=" 01/01/2010 " number=" 1" startdate=" 20/06/2003 ">
            <phase color="CCFFCC" currentdate="20/06/2003" name="Project Start" plandate="20/06/2003" type="phase"/>
            <phase color="CDCD67" currentdate="" name="Concept Closure" plandate="" type="phase"/>
            <phase color="99CCFF" currentdate="20/06/2003" name="Feasibility Closure" plandate="20/06/2003" type="phase"/>
            <phase color="F0FF00" currentdate="" name="Alpha Test" plandate="" type="milestone"/>
            <phase color="F0FF00" currentdate="26/07/2004" name="Beta Test" plandate="31/05/2004" type="milestone"/>
            <phase color="0099FF" currentdate="29/06/2005" name="Commercialization" plandate="08/12/2004" type="phase"/>
            <phase color="CC99FF" currentdate="24/02/2006" name="Project Closed" plandate="01/01/2010" type="phase"/>
            </version>
    <subproject enddate=" 16/10/2008 " id="11809" name="espWatcher Pricing Toolkit" startdate=" 01/08/2003 ">
    <version enddate=" 16/10/2008 " number=" 1" startdate=" 01/08/2003 ">
            <phase color="CCFFCC" currentdate="01/08/2003" name="Project Start" plandate="01/08/2003" type="phase"/>
            <phase color="99CCFF" currentdate="" name="Feasibility Closure" plandate="" type="phase"/>
            <phase color="0099FF" currentdate="15/06/2005" name="Commercialization" plandate="08/12/2004" type="phase"/>
            <phase color="CC99FF" currentdate="16/10/2008" name="Project Closed" plandate="16/10/2008" type="phase"/>
            </version>
    </subproject>
    <subproject enddate=" 31/12/2070 " id="35704" name="espWatcher version 2 (2005)" startdate=" 01/01/2005 ">
    <version enddate=" 31/12/2070 " number=" 1" startdate=" 01/01/2005 ">
            <phase color="CCFFCC" currentdate="01/01/2005" name="Project Start" plandate="01/01/2005" type="phase"/>
            <phase color="99CCFF" currentdate="01/07/2005" name="Feasibility Closure" plandate="01/07/2005" type="phase"/>
            <phase color="0099FF" currentdate="31/03/2006" name="Commercialization" plandate="31/03/2006" type="phase"/>
            <phase color="CC99FF" currentdate="31/12/2070" name="Project Closed" plandate="31/12/2070" type="phase"/>
            </version>
    </subproject>
    </project>
    </program>
    </chart>
    However this solution removes most of the whitespaces, I want exact output as flash file is expecting so..
    Where ever I am calling the CF functions, there I am getting the whitespaces. like below cases.
    startdate="#getProjectStartDate(sProjectIdList)#" -> output I am getting for this statement is -> " 12/09/2009 "
    Please assist me...
    Regards,
    Manoz.

  • XML validation fails

    Hello,
    We are trying to validate an XML against a DTD using XDK 9.2.0.5.0 and it fails. The same XML was validated without any problem earlier, but, suddenly started failing with the following error.
    XML-0201: (Fatal Error) Expected name instead of .
    If I open the above XML in XMLSPY or any other XML parsing tools, the tool is showing as valid xml file.
    Interestingly, if I add a whitespace after encoding statement,but, before ? (<?xml version="1.0" encoding="us-ascii" ?>), the XML is valid with the XDK.
    If I remove the whitespace (<?xml version="1.0" encoding="us-ascii"?>), the XML is invalid with XDK.
    What could have been a problem ?
    Thanks for your time.
    Satya

    Does the error get generated with encoding utf-8.

Maybe you are looking for

  • Regarding the operators used in abap oo

    hi, can any one send me the link or else please give in writing the operators used in oo abap. like ->, =>, ?= etc etc. please send me them i didnot find them in many sites that i am going through . thanks and regards ibrahim.md

  • How to put mail ids in CC and BCC while sending mail through ABAP?

    Hi all, i have created a report which sends the output of the  report to external mail ids. I want to put some email ids in CC or BCC. Please do guide me so that i can proceed with the development. Thanks and Regards, Syed

  • Safari Toolbar Still Too Dark

    Leopard 10.5.2 did not correct the shade and density of the toolbar. Does anyone have suggestions or solutions to lighten the shade? Perhaps a 3rd party app? bolobar

  • Duke stars

    Just found out what duke stars are. It is a good idea. Is it a commonly used system or noboby cares about it? Cause I think we should :) Thanks

  • I can not open photoshop CS5! Please help me!

    I have had CS5 on my mac for a while now... no problems.  All of a sudden photoshop will not open.  Icon flashes once... nothing!!!  Bridge I can access. I have uninstalled and reinstalled 2x's... still nothing.  What can I do?