Using XQuery to filder CDATA section

How do I filter value inside CDATA section using XQUERY in SELECT statement?
I am using value function.
<DomainConfig>
     <typeOfDBConnection>
           <![CDATA[#MS SQL]]>
     </typeOfDBConnection>
</DomainConfig>

declare @x xml = '<DomainConfig>
<typeOfDBConnection>
<![CDATA[#MS SQL]]>
</typeOfDBConnection>
</DomainConfig>
select
ltrim(rtrim(replace(replace(replace
(@x.value ('(/DomainConfig/typeOfDBConnection/text())[1]', 'varchar(100)') , char(10), ''), char(13), ''), char(9), '')
Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

Similar Messages

  • Returning CDATA using XQuery in ALSB

    I would like to know how to pass CDATA section using XQuery in ALSB. This is required as the client application wants certain data with XML tags as string. I used the following:
    <web:getFlightDetails xmlns:web="http://webservices.ods.mwcoe.united.com">
    <web:getFlightDetailsResponse>
    <XMLBODY>
    { fn:concat("<![CDATA[" ),  " ") }
    { $body/FML32/* }
    { fn:concat(("]]>"), " ") }
    </XMLBODY>
    </web:getFlightDetailsResponse>
    </web:getFlightDetails>
    But I get the following response:
    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Header/>
    <soapenv:Body>
    <web:getFlightDetails xmlns:web="http://webservices.ods.mwcoe.united.com">
    <web:getFlightDetailsResponse>
    <XMLBODY>
    " & l t ; " ![CDATA[
    <STATDES>N/A</STATDES>
    <BAGFIN>-1</BAGFIN>
    <INBLK>2007-10-23 07:33:00</INBLK>
    <FLTDETORIG>SFO</FLTDETORIG>
    ]] "& g t ;"
    </XMLBODY>
    </web:getFlightDetailsResponse>
    </web:getFlightDetails>
    </soapenv:Body>
    </soapenv:Envelope>
    Basically the question is how do I pass < & > and not " & l t ;" and " & g t ;". Please space padding is done on purpose here.
    Thanks,
    Channu Kambalyal
    United Airlines.

    here we get it done using instead of
    { fn:concat("<![CDATA[" ), " ") }
    { $body/node() }
    { fn:concat(("]]>"), " ") }
    this:
    { fn:concat("<![CDATA[" ), $body/node(), "]]>") }
    getting a correct response
    ex:
    <XMLBODY>
    <![CDATA[
    <STATDES>N/A</STATDES>
    ]]>
    </XMLBODY>
    but, if there's any namespace on the variable node, we get all replace by <
    ex:
    <XMLBODY>
    " & l t ; " ![CDATA[
    & l t ; a:STATDES xmlns:a="http://localhost/a">N/A & l t ; /a:STATDES>
    ]] "& g t ;"
    </XMLBODY>
    do anybody have any idea why this happens?

  • Problem retrieving Data from a CDATA-Section using XMLDOM

    Hello,
    Ware: Oracle 8.1.7.4 64bit, XDK for PL/SQL Version 9.2.0.3, Solaris8 64bit
    I can't retrieve Data from the CDATA-Section of an XML-String, neither with
    getData(DOMCharacterData) or substringData. Also getLength fails. I get always
    the following error:
    ERROR at line 1:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.ClassCastException
    ORA-06512: at "XML_SCHEMA.XMLCHARDATACOVER", line 0
    ORA-06512: at "XML_SCHEMA.XMLDOM", line 853
    ORA-06512: at "SCHWABE.XML_TEST", line 47
    ORA-06512: at line 1
    I can successfully cast the DOMNode to a CharacterData with makeCharacterData
    and check with isNull (DOMCharacterData) (returns FALSE).
    My Testcase:
    1) A Function which build a XML-Document:
    CREATE OR REPLACE FUNCTION XML_ResponseCalc RETURN VARCHAR2 IS
    doc VARCHAR2(32767);
    BEGIN
    doc :=
    '<?xml version="1.0" encoding="UTF-8"?>
    <RSDecEng>
    <Version>1.00</Version>
    <ResponseCalc>
    <ID>00000000000000000014</ID>
    <Burst>
    <Definition>
    <Count>1</Count>
    <ID>
    <Start>1</Start>
    <Length>4</Length>
    </ID>
    <Var>
    <Name>Risiko_1</Name>
    <Start>5</Start>
    <Length>5</Length>
    </Var>
    </Definition>
    <Data>
    <Length>9</Length>
    <Count>5</Count>
    <![CDATA[
    1 0.001
    2 0.002
    3 0.003
    4 0.004
    5 0.005
    6 0.006
    7 0.007
    8 0.008
    9 0.009
    10 0.010
    ]]>
    </Data>
    </Burst>
    </ResponseCalc>
    </RSDecEng>
    2) The Procedure which parses the XML-Document (no Exception-Handling):
    CREATE OR REPLACE PROCEDURE XML_TEST IS
    Parser XML_SCHEMA.XMLParser.Parser;
    DOMDocument XML_SCHEMA.XMLDOM.DOMDocument;
    DOMNode XML_SCHEMA.XMLDOM.DOMNode;
    DOMNodeItem XML_SCHEMA.XMLDOM.DOMNode;
    DOMNodeList XML_SCHEMA.XMLDOM.DOMNodeList;
    DOMCharacterData XML_SCHEMA.XMLDOM.DOMCharacterData;
    TheDocument CLOB;
    ID VARCHAR2(100);
    Data VARCHAR2(200);
    BEGIN
    -- LOB
    DBMS_LOB.CREATETEMPORARY(TheDocument, TRUE);
    DBMS_LOB.WRITEAPPEND(TheDocument, LENGTH(XML_ResponseCalc), XML_ResponseCalc);
    -- Parse
    Parser := XML_SCHEMA.XMLParser.NewParser;
    XML_SCHEMA.XMLParser.ParseCLOB(Parser, TheDocument);
    DOMDocument := XML_SCHEMA.XMLParser.GetDocument(Parser);
    XML_SCHEMA.XMLParser.FreeParser(Parser);
    -- Node
    DOMNode := XML_SCHEMA.XMLDOM.MakeNode(DOMDocument);
    -- Get ID
    DOMNodeList := XML_SCHEMA.XSLProcessor.SelectNodes
    (DOMNode,'/RSDecEng/ResponseCalc/ID/text()');
    IF XML_SCHEMA.XMLDOM.GetLength(DOMNodeList) > 0 THEN
    DOMNodeItem := XML_SCHEMA.XMLDOM.Item(DOMNodeList, 0);
    XML_SCHEMA.XMLDOM.WriteToBuffer(DOMNodeItem, ID);
    SYS.DBMS_OUTPUT.PUT_LINE ('ID: '||ID);
    END IF;
    -- Get CDATA
    DOMCharacterData := XML_SCHEMA.XMLDOM.MakeCharacterData(DomNode); -- <-- ok here...
    IF NOT XML_SCHEMA.XMLDOM.isNull (DOMCharacterData) THEN -- <-- ...and here
    Data := XML_SCHEMA.XMLDOM.GETDATA(DOMCharacterData); -- <-- ...but here Exception raise
    END IF;
    END;
    I hope you can help me.
    Thank you in advance
    Markus Schwabe

    You need to notice the definitions for makecharacterdata:
    FUNCTION makeCharacterData(n DOMNode) RETURN DOMCharacterData;
    PURPOSE
    Casts given DOMNode to a DOMCharacterData
    It only do the casting.

  • Org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x80) was found in the CDATA section

              Hi,
              I,'m using c.tld tag libraries from Yakarta in order to use c:if functions.
              When I use non-unicode characters in my JSP pages, it crashes:
              java.io.IOException: javax.servlet.jsp.JspException: The taglib validator rejected
              the page: "org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x80)
              was found in the CDATA section., "
                   at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:124)
                   at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:258)
                   at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:353)
                   at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:211)
                   at weblogic.servlet.jsp.JspStub.checkForReload(JspStub.java:149)
                   at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:521)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:351)
                   at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
                   at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5445)
                   at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:780)
                   at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3105)
                   at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2588)
                   at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
                   at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)
              How can I force it to use ISO-8859-1? All my tries haven't work. What should I
              do? The c.tld libraries and jars are taken from JDK 1.4.1_02
              

    Hi Stefan,
       This is my source xml in moni..
    xmlns:prx="urn:sap.com:proxy:ECP:/1SAI/TAS5BFDF495190544E4B506:701:2008/06/06">
      <SiteId>0080</SiteId>
      <UCC>42027519 91029010015</UCC>
    My interface is SAP(Proxy) to Database(Synchronous).
       SAP (PROXY) --> PI --> DATABASE ( Synchronous Communication )
    Let me know if u need any information from my side...
    Thanks for ur help...
    Thanks,
    Siva..

  • Problem: Storing binary data in Xml Cdata section

    The objective : Tranport image using xml
    1. I convert the image to input stream.
    2. store it in an array.
    3. encode the string using Base64 library and get a string
    4.then i store it in xml CDATA section.
    the code snippet is
    public class ImgToXml01 {
         public static void main(String[] args) throws IOException
              File inputFile = new File("C:\\Arup\\ImgXml\\read\\Sample.jpg");
              FileInputStream in = new FileInputStream(inputFile);
              String str="";
              int c;
              while ((c = in.read()) != -1) {
              str+= ""+c;
              String val = util.Base64.encode(str);
              System.out.println(""+val);
              OutputStream fout = new FileOutputStream("img.xml");
              OutputStreamWriter out = new OutputStreamWriter(fout);
              out.write("<?xml version = \"1.0\" encoding = \"ISO-8859-1\"?>\r\n");
              out.write("<Image>\r\n");
              out.write("[CDATA["+val+"]]");
              //out.write("]]>");
              out.write("</image>\r\n");
              out.close();
    When i retrieve it i write the code:
    import org.xmldb.api.base.*;
    import org.xmldb.api.modules.*;
    import org.xmldb.api.*;
    import org.w3c.dom.*;
    import java.io.*;
    import org.xml.sax.SAXException;
    import oracle.xml.parser.v2.*;
    public class CdataToImage01 {
         public static void main(String[] args) //throws IOException
         try{
         String uri="c:\\Arup\\ImgXml\\img1.xml";
         String data="";      
         File file = new File(uri);
         FileInputStream fis = new FileInputStream(file);
         BufferedInputStream in = new BufferedInputStream(fis);      
         DOMParser parser = new DOMParser();
         parser.parse(in);      
         Document doc = parser.getDocument();
         Node r = doc.getElementsByTagName("Image").item(0);          
         NodeList kids = r.getChildNodes();
         if ( kids != null )     {
              for ( int i = 0; i < kids.getLength(); i++ ) {
                   if ( (kids.item(i).getNodeType() == Node.TEXT_NODE) ||
                             (kids.item(i).getNodeType() == Node.CDATA_SECTION_NODE)) {
                             data=kids.item(i).getNodeValue();
              String data1 = util.Base64.decode(data);
              File outputFile = new File("Sample.jpg");
              FileOutputStream out = new FileOutputStream(outputFile);      
              byte[] buff = data1.getBytes();
              InputStream inn = new ByteArrayInputStream(buff);
              int c;
              System.out.println(buff.length);
              while ((c = inn.read()) != -1) {
              out.write(c);
              inn.close();
              out.close();
         catch (SAXException e) {
              System.err.println(e);
              e.printStackTrace();
         catch (Exception ex){
              System.err.println("Exception occured " + ex.getMessage());
              ex.printStackTrace();
    But i am not getting the appropriate result .I get a corrupted image.
    FROM
    ARUP GHOSH

    String str="";
    int c;
    while ((c = in.read()) != -1) {
    str+= ""+c;
    }Your problem is here.
    Let's suppose you just have a trivial 3-byte file containing the bytes 27, 55, and 126. Your program will convert that into the string "2755126". Then you base-64 encode it, etc etc, then you base-64 decode it and (hopefully) produce the same string "2755126". Converting this string to bytes and writing it to a file produces a 7-byte file containing the bytes 50, 55, 53, 53, 49, 50, and 54. Not the same at all. You could prove this to yourself by putting in some debugging statements.
    I don't know how to suggest a fix because it looks to me as if your base-64 utility takes a String as its input. It should take an array of bytes, or an InputStream.
    PC&#178;

  • Confused with CDATA section

    Hi,
    I am confused as to how the DOM tree is formed for the following XML
    <Template>
    <Query>
    <sql name="A">
    <![CDATA[
    SELECT     name from salary where salary >1000;
      ]]>
    </sql>
    <sql name="B">
    <![CDATA[
    SELECT    *            FROM         EMPLOYEES
                WHERE       rownum <= 2;
      ]]>
    </sql>
    </Query>
    </Template>I want to know how the tree for the above XML is formed
    ELEMENT
    --Text
    --CDATA Element
    --Text
    I have used xpath to get a NodeList
    XPATH QUERY => Template/Query/sql
    The NodeList is passed to a function to get the sql query inside CDATA,
    This is the function I wrote
    public static void traverseCData(NodeList rootNode){
    for(int index = 0; index < rootNode.getLength();
    index ++){
    Node aNode = rootNode.item(index);
    printNodeType(aNode);
    if (aNode.getNodeType() == Node.CDATA_SECTION_NODE){
    Node firstChild = aNode.getFirstChild();
    System.out.println("FirstChild => "); printNodeType(firstChild);
    if(firstChild.getNodeType() == Node.TEXT_NODE){
    System.out.println("NodeName " + firstChild.getNodeName());
    System.out.println("Node Value " + firstChild.getNodeValue());
    System.out.println("Text Content " + firstChild.getTextContent());
    traverseCData(aNode.getChildNodes());
    Please clarify
    1) If the DOM tree for the NodeList I have assumed above is right
    2) How do I traverse the CData section above. I actually need to replace the sql query in the CDATA section with a new sql query. Can you please help me how to proceed.
    Thanks
    Kart

    1) If the DOM tree for the NodeList I have assumed above is rightI would suggest a simple test program that just dumps out the DOM structure would be the best way of finding if your assumption is true.

  • CDATA section in a tag of an XML file

    Hi SDNers:
    I have an issue with using the method CREATE_CDATA_SECTION of Interface IF_IXML_DOCUMENT.
    I have created an XML file from ABAP using methods in IF_IXML_DOCUMENT etc.
    The XML file is perfectly alright. But now there's a need to add CDATA section.
    I need the CDATA section as follows in XML file...
    <CustomField>
        <![CDATA[
              First Line of Text
              Second line of Text
              Third Line of Text
          ]]>
    </CustomField>
    but don't know how to program this. Can anybody help/advice me on this?
    Looking forward to your optimum response(s).
    Best Regards

    Hi SDNers:
    I have an issue with using the method CREATE_CDATA_SECTION of Interface IF_IXML_DOCUMENT.
    I have created an XML file from ABAP using methods in IF_IXML_DOCUMENT etc.
    The XML file is perfectly alright. But now there's a need to add CDATA section.
    I need the CDATA section as follows in XML file...
    <CustomField>
        <![CDATA[
              First Line of Text
              Second line of Text
              Third Line of Text
          ]]>
    </CustomField>
    but don't know how to program this. Can anybody help/advice me on this?
    Looking forward to your optimum response(s).
    Best Regards

  • How to identify a CDATA section in DOM API?

    I'm having a problem reading a CDATA section from using the DOM API. A call to Node.getNodeType() doesn't return CDATA_SECTION_NODE as expected but returns TEXT_NODE. Also, a call to getValue() doesn't return <![CDATA[<foo>]]> but returns
    <foo> instead. Does anyone know how to get getNodeType() to return the proper value?
    For example suppose I have the following XML:
    <?XML version="1.0"?>
    <document>
    <elm><![CDATA[text with <b>HTML</b>]]></elm>
    </document>
    A call to getNodeType() for the value Node (the child of the <elm> node) returns TEXT_NODE. I would expect it to return CDATA_SECTION_NODE.
    Ken

    C'mon Oracle people -- help me out here,
    Is this a known bug or what? I just discovered that if you do a cloneNode()
    the CDATA section gets messed up, too.
    Ken
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Kenneth Liu ([email protected]):
    I'm having a problem reading a CDATA section from using the DOM API. A call to Node.getNodeType() doesn't return CDATA_SECTION_NODE as expected but returns TEXT_NODE. Also, a call to getValue() doesn't return <![CDATA[<foo>]]> but returns
    <foo> instead. Does anyone know how to get getNodeType() to return the proper value?
    For example suppose I have the following XML:
    <?XML version="1.0"?>
    <document>
    <elm><![CDATA[text with <b>HTML</b>]]></elm>
    </document>
    A call to getNodeType() for the value Node (the child of the <elm> node) returns TEXT_NODE. I would expect it to return CDATA_SECTION_NODE.
    Ken<HR></BLOCKQUOTE>
    null

  • Problem while creating xml with cdata section

    Hi,
    I am facing problem while creating xml with cdata section in it. I am using Oracle 10.1.0.4.0 I am writing a stored procedure which accepts a set of input parameters and creates a xml document from them. The code snippet is as follows:
    select xmlelement("DOCUMENTS",
    xmlagg
    (xmlelement
    ("DOCUMENT",
    xmlforest
    (m.document_name_txt as "DOCUMENT_NAME_TXT",
    m.document_type_cd as "DOCUMENT_TYPE_CD",
    '<![cdata[' || m.document_clob_data || ']]>' as "DOCUMENT_CLOB_DATA"
    ) from table(cast(msg_clob_data_arr as DOCUMENT_CLOB_TBL))m;
    msg_clob_data_arr is an input parameter to procedure and DOCUMENT_CLOB_TBL is a pl/sql table of an object containing 3 attributes: first 2 being varchar2 and the 3rd one as CLOB. The xml document this query is generating is as follows:
    <DOCUMENTS>
    <DOCUMENT>
    <DOCUMENT_NAME_TXT>TestName</DOCUMENT_NAME_TXT>
    <DOCUMENT_TYPE_CD>BLOB</DOCUMENT_TYPE_CD>
    <DOCUMENT_CLOB_DATA>
    &lt;![cdata[123456789012345678901234567890123456789012]]&gt;
    </DOCUMENT_CLOB_DATA>
    </DOCUMENT>
    </DOCUMENTS>
    The problem is instead of <![cdata[....]]> xmlforest query is encoding everything to give &lt; for cdata tag. How can I overcome this? Please help.

    SQL> create or replace function XMLCDATA_10103 (elementName varchar2,
      2                                             cdataValue varchar2)
      3  return xmltype deterministic
      4  as
      5  begin
      6     return xmltype('<' || elementName || '><![CDATA[' || cdataValue || ']]>
      7  end;
      8  /
    Function created.
    SQL>  select xmlelement
      2         (
      3            "Row",
      4            xmlcdata_10103('Junk','&<>!%$#&%*&$'),
      5            xmlcdata_10103('Name',ENAME),
      6            xmlelement("EMPID", EMPNO)
      7         ).extract('/*')
      8* from emp
    SQL> /
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[SMITH]]></Name>
      <EMPID>7369</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[ALLEN]]></Name>
      <EMPID>7499</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[WARD]]></Name>
      <EMPID>7521</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[JONES]]></Name>
      <EMPID>7566</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[MARTIN]]></Name>
      <EMPID>7654</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[BLAKE]]></Name>
      <EMPID>7698</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[CLARK]]></Name>
      <EMPID>7782</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[SCOTT]]></Name>
      <EMPID>7788</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[KING]]></Name>
      <EMPID>7839</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[TURNER]]></Name>
      <EMPID>7844</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[ADAMS]]></Name>
      <EMPID>7876</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[JAMES]]></Name>
      <EMPID>7900</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[FORD]]></Name>
      <EMPID>7902</EMPID>
    </Row>
    <Row>
      <Junk><![CDATA[&<>!%$#&%*&$]]></Junk>
      <Name><![CDATA[MILLER]]></Name>
      <EMPID>7934</EMPID>
    </Row>
    14 rows selected.
    SQL>

  • XI File Sender CC, CDATA Sections

    Hello all,
    i configured a File Sender CC with content conversion but the
    integration engine gives me a parser exception because there are characters in the file which are not allowed for a field without CDATA section. Can i configure somewhere that for the content conversion CDATA sections are used ?
    Thx !
    Andreas

    Hi Andreas,
               Yes as the XML parser does not understand "'" char in the FIELD1 string, it gives the following errore. So to do that you need to put the following in CDATA, as the XML parser ignores anuting between CDATA.
    To acheive CDATA you need to implement XSLT mapping.
    Check out this link: <a href="/people/michal.krawczyk2/blog/2005/11/01/xi-xml-node-into-a-string-with-graphical-mapping Mapping</a>
    The code mentioned below is relevant to the example in the blog:
    Pls follow the following steps to insert XML string into a single element:
    Create a xsl file with the following data:
    <?xml version='1.0' ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" NSpace>
    <xsl:template match="/">
    <namespace:name1>
    <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text><xsl:copy-of select="//namespace:name"/><xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text><xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
    </namespace:name1>
    </xsl:template>
    </xsl:stylesheet>
    In the above code I have removed xmlns:p2="http://frik.bcc.com.pl" which is not needed.
    Also you have to put '//' before the target element from where you want to start creating XML string over here it is name. And name1 is the element you want to store the XML string in.
    So anything in the element name will be stored in name1
    Regarding the namespace: To find out the namespace test your message mapping between the source and the target without adding XSLT mapping. After testing click on 'SCR' tab present on top of the target window. There you will see ns1: or ns2: attached to each element. Replace namespace in the above code with ns1: or ns2:. And replace NSpace in the above XSL Header with the namespace in the SCR of test map.
    So the final XSL file will look like that:
    <?xml version='1.0' ?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns1="http://sap.com/xi/HR">
    <xsl:template match="/">
    <ns1:name1>
    <xsl:text disable-output-escaping="yes"><![CDATA[<![CDATA[]]></xsl:text><xsl:copy-of select="//ns1:name"/><xsl:text disable-output-escaping="yes"><![CDATA[]]]]></xsl:text><xsl:text disable-output-escaping="yes"><![CDATA[>]]></xsl:text>
    </ns1:name1>
    </xsl:template>
    </xsl:stylesheet>
    Dont forget to put '//' before the target element.
    This should work. Or pls put the source and target xml struct and we will assist you further.
    Regards,
    Ashish

  • Xsl output attributes for cdata-section-elements and doctype-system

    I am using an xsl file to transform one xml document to another xml document. I want to use the xsl:output Element to do two things:
    1.Generate CDATA sections for the text contained in an xml element,"Description"
    2. Add the line "<!DOCTYPE PartInformation SYSTEM "part.dtd">
    I am using the following code in the xsl file to do these two things, but it does not seem to be doing anything.
    <xsl:output cdata-section-elements="Description" doctype-system="part.dtd"/>
    Does anybody have any idea what's happening?
    Thanks
    Kishore

    Would you specify the XDK version and supply a simple sample including XML and XSL file?

  • CDATA sections converted to text nodes by XMLDOM parser

    I have done a lot of reading, experimentation and openned a TAR on this. I am suprised nobody else has posted on the issue. The xmlparser.parseClob call appears to parse an XML document properly but converts CDATA sections into text nodes.
    For example take the following XML:
    <some><pnode><![CDATA[the <xml>]]></pnode></some>
    If I immediately write it back out using xmldom.writeToClob the resulting XML will be:
    <some>
    <pnode>the &amp;#60;xml></pnode>
    </some>
    For one I wish writeToClob wouldn't add whitespace (but that's another issue), but as you can see the CDATA node no longer exists, being replaced by an encoded text node.
    I wrote code to traverse the DOM outputting node types and even writing a similar printer to the writeToClob. The fact is there really is no CDATA node in the DOM after parsing. Instead the code which traverses the DOM identifies a single text node with CDATA text contained in it.
    In my opinion this is extremely odd default behavior and I cannot seem to work around it due to the fact that the DOM structure is not created properly by the parse. Please tell me that other people have ran into this behavior and I'm not just nuts? Better yet, please just tell me I'm doing something wrong and you have the answer...that would be kinder to my project schedule.
    If you like I have example code. I am using the xmldom API on Oracle 9.2.0.4.

    Thanks for the response Mark. I have gotten some feedback from my TAR as well. We are using version 9.2.0.*. I have since learned that this is a bug in the xmldom implementation based on Java. It has been recommended that I use the dbms_* packages as you suggested. I originally attempted to use the dbms_* packages (the C-based implementation) when following the tutorials and other documentation but for some reason we do not seem to have those packages installed. I was directed by my DBA's to use the other package as we both bevelieved it was just the same package in a different location. I am working with my DBA to get the C-based dbms_* packages installed.

  • CreateCDATASection() method doesn't creates a CDATA Section.

    Hi,
    While using Oracle XDK, if I try to create a CDATA Section using createCDATAsection() method, it doen't creates a CDATA Section. Instead it creates a normal Text node. If I try the same code with Apache Xerces, it works fine and I have CDATA section.
    The problem I am facing because, my node data has some special characters and I don't want parser to validate that. Has anyone else faced the same problem or have a work around?
    Any help will be appreciated.
    Thanks,
    Atif

    The double square bracket closing the CDATA section was never a problem. I had issues with LrXml encoding the opening angle bracket as an &lt; entity:
        local xml = LrXml.createXmlBuilder(false)
        xml:beginBlock("var")
        xml:tag("name", "var1")
        xml:beginBlock("value")
        xml:tag("string", "<![CDATA[value123]]>")
        xml:endBlock()
        xml:endBlock()
        local strXML = xml:serialize()
    Produces the following maligned XML:
    <?xml version="1.0"?>
    <var>
    <name>var1</name>
    <value>
    <string>&lt;![CDATA[value123]]></string>
    </value>
    </var>
    I guess one way to go about it is to run serialized XML through string.gsub to un-encode the "&lt;![CDATA[" sequence as follows:
    strXML = string.gsub(strXML, "&lt;!%[CDATA%[", "<![CDATA[")
    This is a nasty workaround, but this appears to be the only way to get the job done. Now my serialized XML looks as expected:
    <?xml version="1.0"?>
    <var>
    <name>var1</name>
    <value>
    <string><![CDATA[value123]]></string>
    </value>
    </var>
    This only leaves me wondering as to why LrXml doesn't support CDATA sections through its API, they are not that uncommon...

  • How do i return a CDATA section in a SOAP response?

    hi,
    i am relatively new to SOAP/web services. but i know what i want ;-). i naively thought that i could simply send a CDATA wrapped string in a SOAP response by simply doing SOAPElement.addTextNode("<![CDATA[..."). of course, WLS 8.1's javax.xml.soap implementation escapes the <pre>"<" & ">"</pre> as <pre>"<" and ">"</pre> in the response.
    IF i could use the saaj 1.2 implementation, i would do something along the lines of the following to return a CDATA section in a SOAP response :
    <pre>  
       org.w3c.dom.CDATASection myCDATASection ...;
       SOAPBodyElement myBodyElement ...;
       myBodyElement.appendChild(myCDATASection);
    </pre>
    or maybe even something like:
    <pre>
       String myCDATAString = "<![CDATA[...]]>";
    javax.xml.soap.SOAPBody soapBody = ...;
    javax.xml.parsers.DocumentBuilder builder = ...;
    org.xml.sax.InputSource.InputSource inputSource = ...;
    org.w3c.dom.Document document = builder.parse(inputSource);
    soapBody.addDocument(document);
    </pre>          
    but that is a BIG IF! of course, as i have learned after a lengthy trawl through this ng, WLS 8.1 uses its own implementation of the javax.xml.soap.* classes. in particular, weblogic's SOAPBody implementation is devoid of an addDocument(org.w3c.dom.Document) method. and SOAPBodyElement does not have an appendChild(org.w3c.dom.Node)
    please, can anybody fill me in on how to go about doing what i am trying to do using WLS 8.1's javax.xml.soap classes?
    many thanks

    if anybody else out there is also trying to do what i have described (return xml text in a soap response), the solution (told to me by my company's BEA rep) is to just add the raw xml text to the SOAPElement.addTextNode() and weblogic will do the right thing (namely, escape whatever needs to be escaped).
    i had been lead to believe that you couldn't send entity refs (<pre>< and ></pre>) in a soap response. i was told i needed to wrap my raw xml in a CDATA section. but actually i don't need a CDATA section after all for the response i need to return (xml text). contrary to what i was lead to believe by another developer, entity refs are not a problem in a soap response (according to BEA, anyway).

  • Newline inserted into CDATA section by parser

    I'm parsing an xml file with a CDATA value that contains xml content. After parsing the file, I display the CDATA value within a JTextArea. For some reason, this xml content ends up double-spaced (hex data 0D 0A 0D 0A, instead of just the original 0D 0A at the end of each line). A newlines are being inserted into my CDATA data. I thought the parser wasn't supposed to change this data.
    I'm extending the SAX DefaultHandler and don't implement the LexicalHandler. Am I supposed to implement the LexicalHandler interface when using CDATA?

    The character data within the CDATA section is being altered. Though I will admit that my original data was incorrect (see below).
    Below is an excerpt form my CDATA section:
    <Configuration>
      <BaseDeviceID>
    ...The hex character data that I see between these two tags (after the first ">" and before the second "<") at different stages is shown below.
    In the original XML file on disk, using a hex editor:
    0D 0A 20 20
    Input to the characters(...) method of my SAXEventHandler during parsing:
    0A 0A 20 20
    Copied from the displayed text in the JTextArea to the hex editor after parsing:
    0D 0A 0D 0A 20 20 (this is where my original data came from)
    It appears that the XML processor (parser?) is changing the carriage return (0D) to a linefeed (0A). This shouldn't happen even if section 2.11 of the spec applies.

Maybe you are looking for

  • How do I get my appletv to update its itunes data?

    I am streaming most of my itunes library and not syncing it.  However, as I add things especially m4v files to itunes they don't show up on my AppleTV 1stgen right away.  I almost always have to restart it.  And even then the files won't always play

  • Playlist Sync Issues with new iPod Touch 8G

    Hi Guys - This my first post. Just got an iPod Touch 8G for Christmas, and I'm having some issues with Syncíng it and would appreciate some guidance. I previously used a Sony PSP as my portable music player, and so my music is organised into folders,

  • HELP! [project won't open on different computer]

    I finish a project and saved it in my hard disk. And now, I am trying to open it on another computer but it can't be opened and it state that it's damaged or something. What should I do?

  • Printer will only print 2 pages then say error - windows 8

    Hi, we have purchased a new laptop to make life simpler, only things never end up being that way. Currently we are having trouble printing more than 1 page, the computer on the second page half way through will bleep and an error message will be disp

  • AppleTV Streaming Query

    I have a MacMini under my TV which I use as a media machine to service all my video content in the living room. Its running Snow Leopard with the Perian plugin to give me access to content not supported natively by iTunes/Quicktime. Now all is fine w