Generate own xml tags

Hi,
I have to generate an xml file out of a table in oracle.
Thats my test function
DECLARE
queryCtx dbms_xmlquery.ctxType;
result CLOB;
BEGIN
-- set up the query context
queryCtx := dbms_xmlquery.newContext('Select
     empno "EMP_NO"
, ename "NAME"
, deptno "DEPT_NO" from test_emp'
-- set row tag name and row set tag name
dbms_xmlquery.setRowTag(
queryCtx
, 'EMP'
dbms_xmlquery.setRowSetTag(
queryCtx
, 'EMPSET'
-- run query and print out result
result := dbms_xmlquery.getXml(queryCtx);
printClobOut(result);
-- free resources
dbms_xmlquery.closeContext(queryCtx);
END;
the result is an xml like that:
<?xml version = '1.0'?>
<EMPSET>
<EMP num="1">
<EMP_NO>7369</EMP_NO>
<NAME>Smith</NAME>
<DEPT_NO>20</DEPT_NO>
</EMP>
</EMPSET>
but now i have to set own tags around a row in the table... for example:
<?xml version = '1.0'?>
<EMPSET>
<EMP num="1">
<ownTag>
<EMP_NO>7369</EMP_NO>
<NAME>Smith</NAME>
<DEPT_NO>20</DEPT_NO>
</ownTag>
</EMP>
</EMPSET>
I searched now around two hours and nothing found..
can anybody help me

try xdb-forum here at OTN...

Similar Messages

  • Generating target XML tag from a value in the Source XML document

    Hi there,
    I have a scenario where the following transformation needs to occur:
    Source Message...
    <Catalogue>
      <key>abc<\key>
      <value>123<\value>
      <key>def<\key>
      <value>456<\value>
    <\Catalogue>
    Target Message...
    <Catalogue>
      <abc>123<\abc>  --> Value of KEY becomes the XML tag and the VALUE gets assigned to it
      <def>456<\abc>
    <\Catalogue>
    The target message is written to an xml file using the receiver file adapter.
    I would like the target message generation to be dynamic so that when a new key-value pair is added, it would not require a change in the XI mapping layer.  Is there a way to accomplish this without having to code or enhance the adapter.  I am trying to avoid doing this in the mapping because that would mean changing the mapping every time a new key-value pair needs to be added.
    Any suggestions to accomplish this are welcome.
    Thanks all.

    Hi,
    I doubt if it will work for you. you can generate dynamic values using this but not tags dynamically. You need to see if there are any methods to generate tags dynamically.
    One way of doing this is by using Java Mapping and playing around with InputStream and OutputStream.It will work for sure with this.
    Thanks
    Amit

  • How to generate blank xml tag when encounter null elements in it

    Hi Gurus,
    Iam facing one issue in generating the blank tag, here is my file which I am generating right now
    <HEADER>
        <MINISTRY_CODE>RPO</MINISTRY_CODE>
        <DEPARTMENT_CODE>000</DEPARTMENT_CODE>
        <ORDER_CODE>RPO000EPO11001002</ORDER_CODE>
        <EXTERNAL_SYSTEM_CODE>E</EXTERNAL_SYSTEM_CODE>
        <AMENDMENT_NUMBER>0</AMENDMENT_NUMBER>
        <VARIATION_NUMBER>0</VARIATION_NUMBER>
        <EXCEPTIONS>
          <EXCEPTION>
            <EXCEPTION_CODE>PO016</EXCEPTION_CODE>
            <EXCEPTION_LONG_DESC>PO cannot be created/amended successfully</EXCEPTION_LONG_DESC>
          </EXCEPTION>
        </EXCEPTIONS>
      </HEADER>
      <ITEMS>
        <ITEM>
          <LINE_NUMBER>1</LINE_NUMBER>
          <EXCEPTIONS>
            <EXCEPTION>
              <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
              <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
            </EXCEPTION>
          </EXCEPTIONS>
          <LOCATIONS>
            <LOCATION>
              <LINE_NUMBER>1</LINE_NUMBER>
              <EXCEPTIONS>
                <EXCEPTION>
                  <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
                  <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
                </EXCEPTION>
              </EXCEPTIONS>
              <DISTRIBUTIONS>
                <DISTRIBUTION>
                  <LINE_NUMBER>1</LINE_NUMBER>
                  <EXCEPTIONS>
                    <EXCEPTION>
                      <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
                      <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
                    </EXCEPTION>
                  </EXCEPTIONS>
                </DISTRIBUTION>
              </DISTRIBUTIONS>
            </LOCATION>
          </LOCATIONS>
        </ITEM>
      </ITEMS>
    </GEBIZ_ORDER_ACK>current I am generating EXCEPTION tag even if it is null like
    <EXCEPTIONS>
    <EXCEPTION>
    <EXCEPTION_CODE xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
    <EXCEPTION_LONG_DESC xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
    </EXCEPTION>
    </EXCEPTIONS>
    but my requirement is not generate them when exception code is null and only generate like
    <EXCEPTIONS/>
    this is sql i am using to generate the above said code let me know how can i control that
                       SELECT xmlserialize(document
                                  xmlelement("GEBIZ_ORDER_ACK"
                                  , xmlagg(
                                      xmlconcat(hdr, dtls)
                                  as clob indent size = 2
                       --  INTO lv_out
                         FROM (
                               SELECT xmlelement("HEADER"
                                           , xmlelement("MINISTRY_CODE", poh.ministry_code)
                                           , xmlelement("EXCEPTIONS"
                                                 , xmlelement("EXCEPTION"
                                                             , xmlelement("EXCEPTION_CODE"   --,NVL(poh.exception_code,'NULL')
                                                             , xmlattributes(
                                                               NVL2(poh.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                             , NVL2(poh.exception_code,null,'true') as "xsi:nil"
                                                             ,poh.exception_code)
                                                             , xmlelement("EXCEPTION_LONG_DESC"
                                                             , xmlattributes(
                                                               NVL2(poh.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                             , NVL2(poh.exception_long_desc,null,'true') as "xsi:nil"
                                                             ,poh.exception_long_desc)
                                           ) hdr
                                     , xmlelement("ITEMS"
                                     , xmlagg(
                                              xmlelement("ITEM"
                                               ,xmlelement("LINE_NUMBER", v1.line_no)
                                               ,xmlelement("EXCEPTIONS"
                                                        , xmlelement("EXCEPTION"
                                                                    , xmlelement("EXCEPTION_CODE"    --,NVL(v1.exception_code,'NULL')
                                                                    , xmlattributes(
                                                                      NVL2(v1.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                                    , NVL2(v1.exception_code,null,'true') as "xsi:nil"
                                                                    , v1.exception_code)
                                                                    , xmlelement("EXCEPTION_LONG_DESC"
                                                                    , xmlattributes(
                                                                      NVL2(v1.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                                    , NVL2(v1.exception_long_desc,null,'true') as "xsi:nil"
                                                                    ,v1.exception_long_desc)
                                               ,xmlelement("LOCATIONS"
                                               ,( SELECT xmlagg(
                                                          xmlelement("LOCATION"
                                                        , xmlelement("LINE_NUMBER",v2.location_line_no)
                                                        , xmlelement("EXCEPTIONS"
                                                        , xmlelement("EXCEPTION"
                                                        , xmlelement("EXCEPTION_CODE"   --,NVL(v2.exception_code,'NULL')
                                                        , xmlattributes(
                                                          NVL2(v2.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                        , NVL2(v2.exception_code,null,'true') as "xsi:nil"
                                                        , v2.exception_code)
                                                        , xmlelement("EXCEPTION_LONG_DESC"
                                                        , xmlattributes(
                                                          NVL2(v2.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                        , NVL2(v2.exception_long_desc,null,'true') as "xsi:nil"
                                                        ,v2.exception_long_desc)
                                               ,xmlelement("DISTRIBUTIONS"
                                               ,(SELECT xmlagg
                                                 (       xmlelement("DISTRIBUTION"
                                                         ,xmlelement("LINE_NUMBER", v3.distribution_line_no)
                                                         ,xmlelement("EXCEPTIONS"
                                                         , xmlelement("EXCEPTION"
                                                         , xmlelement("EXCEPTION_CODE"--,NVL(v3.exception_code,'NULL')
                                                         , xmlattributes(
                                                           NVL2(v3.exception_code,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                         , NVL2(v3.exception_code,null,'true') as "xsi:nil"
                                                         ,v3.exception_code)
                                                         , xmlelement("EXCEPTION_LONG_DESC"
                                                         , xmlattributes(
                                                           NVL2(v3.exception_long_desc,null,'http://www.w3.org/2001/XMLSchema-instance') as "xmlns:xsi"
                                                         , NVL2(v3.exception_long_desc,null,'true') as "xsi:nil"
                                                        ,v3.exception_long_desc)
                                                          ) ORDER BY v3.distribution_line_no
                                                       ) FROM xgbz_fin_stage_ack_pot_v@dev_1157.RP.EDU.SG v3
                                                        WHERE v2.po_cont_code = v3.po_cont_code
                                                          AND v2.line_no = v3.line_no
                                                          AND v2.location_line_no = v3.location_line_no
                                                          AND v2.fs_timestamp = v3.fs_timestamp
                                                          AND v3.tx_timestamp IS  NULL
                                                 ) ORDER BY v2.location_line_no
                                              ) FROM xgbz_fin_stage_ack_pol_v@dev_1157.RP.EDU.SG v2
                                               WHERE v2.line_no = v1.line_no
                                                 AND v2.po_cont_code = v1.po_cont_code
                                                 AND v2.fs_timestamp = v1.fs_timestamp
                                                 AND v2.TX_TIMESTAMP IS NULL
                             ) ORDER BY v1.line_no
                         ) dtls
                    FROM xgbz_fin_stage_ack_poh_v@dev_1157.rp.edu.sg poh,
                         xgbz_fin_stage_ack_pod_v@dev_1157.rp.edu.sg v1
                   WHERE v1.po_cont_code = poh.po_cont_code
                     AND v1.fs_timestamp = poh.fs_timestamp
                     AND v1.tx_timestamp IS NULL
                     AND poh.tx_timestamp IS NULL
                     AND poh.po_cont_code = rec_po_ack.po_cont_code
                   GROUP BY poh.po_cont_code,poh.ext_system_code,poh.amendment_no,poh.variation_no,poh.exception_code,poh.exception_long_desc,
                            poh.ministry_code, poh.dept_code)This is urgent please help in this regard.
    thanks in advance.
    Regards
    Nagendra

    Hi,
    Here are two possible solutions :
    xmlelement("EXCEPTIONS",
      xmlforest(
        xmlforest(
          v1.exception_code as "EXCEPTION_CODE"
        , v1.exception_long_desc as "EXCEPTION_LONG_DESC"
        ) as "EXCEPTION"
    )or,
    xmlelement("EXCEPTIONS",
      case when v1.exception_code is not null
             or v1.exception_long_desc is not null
        then xmlelement("EXCEPTION",
               xmlforest(
                 v1.exception_code as "EXCEPTION_CODE"
               , v1.exception_long_desc as "EXCEPTION_LONG_DESC"
      end
    )

  • Generate lowercase XML tags

    Hi,
    In my PL/SQL procedures, I generate XML files based on SQL queries, like this:
    SELECT XMLELEMENT ("web_vpreparations",
    XMLAGG(
    XMLELEMENT ("web_vpreparation",
    XMLFOREST (CODE as "code",
    COMMERCIAL_NAME as "commercial_name",
    As you can see, I rename my column names to their lower-case equivalents, because the client-side application which processes the XML file expects them to be in lower-case.
    I now have a huge view with hundreds of columns and would like to avoid having to rename each one. Is there a chance I can tell the PL/SQL or the SQL to return the XML nodes in lower-case?
    Suggestions on the "SQL and PL/SQL" and "XML DB" forums range from using XMLTable (incompatible with 9i, which some of my customers have) to transforming the generated XML via XSLT (I'd rather change the client-side code than add so much extra processing). Also, I see that DBMS_XMLGEN has a function called useLowerCaseTagNames(); but that means dumping XML/SQL for DBMS_XMLGEN, which - according to Ken Atkins' "XML Data Into and Out of Oracle – Using PL/SQL" - is limited in use for "real World" projects.
    I'm currently learning PL/SQL, experimenting with all the possibilities, and seeking the best solutions for the long-term (in terms of development time, performance, functionality, support).
    I'll appreciate any help on this problem.
    Chris.

    Does anyone know if XMLFormat passed to SYS_XMLGEN can convert the tags to lowercase? Its processingIns (processing instructions) parameter seems like it might help, but I'm unable to find a good description/example on the Web...

  • How to add Multiple XML Tags for a single column for an RDF

    Hi Gurus,
    I have Requirement in the Oracle D2k Report from which we are generating the xml tags.
    My Requirement is in a table i have 2 columns say A and B.
    i am able to generate three xml tags separately using the report builder by clicking on the column name and in the xml setting giving the xml tag.
    eg: table Acount contains 2 columns A and B with respective data
    A B
    QT 1
    QTS 0
    QTR 2
    i am able to general xml tags like this
    <ACount>
    <AStatus>QT</AStatus>
    <HeadCount>1</HeadCount>
    </ACount>
    <ACount>
    <AStatus>QTS</AStatus>
    <HeadCount>0</HeadCount>
    </ACount>
    my requiremnt for the xml tags is
    <ACount>
    <AStatusQT>1</AStatusQT>
    <AStatusQTS>0</AStatusQTS>
    </ACount>
    kindly help me out how to achieve this requirment in the rdf file mulitple xml tags.
    all your input are most valuable to me, thanks in advance
    Edited by: 909577 on Apr 9, 2012 3:10 PM

    I'm sorry for being so dense, but I'm not quite following, although what I've tried makes me think if I can follow you, it will work :)
    To answer your initial questions, you are correct with both your assumptions:
    1) detailType is the parameter that specificies YTD/Weekly, this is a "report defined" parameter that I am using to determine which Row Group to display (either YTD or Weekly)
    2) SchoolDaysActiveWeek is the parameter that is being set to either true or false -- this is a field in the cube that states whether that record is for the current week or not
    So in following your instructions, well that's the problem I'm not quite following :)
    1) When you say Delete the SchoolDaysActiveWeek parameter from the report only, do you mean to mark the parameter as Hidden?  If so, I've done this.
    2) I'm not quite sure where to use the statement you provided me.  You said to put it in the dataset, but I don't know which dataset.  I assume you mean the "main" dataset (as opposed to the hidden dataset that gets generated when you mark a field
    as a parameter).  If this is the case, the only place I could see that would allow you to use such a statement is in the Filter section of the properties.  I tried this, and it did not generate any errors, but it also kept my report groups from displaying
    -- it just showed a blank report, so I think it probably wasn't bringing back any rows to populate them with.
    I also tried going into the Expression section for the SchoolDaysActiveWeek parameter in the second screenshot and placing the statement there.  When I did this and ran the report, I would get the following error:
    The 'SchoolDaysActiveWeek' parameter is missing a value
    So what am I missing!? 
    Also, thanks for taking the time to respond!!

  • URGENT start tag needs to be generated in xml output

    I am getting the xml output as below
    since my value for each element is empty doesn't generate the start tag. BUT I NEED START TAG also to be created with this xml file. What property need to specify while generating it thro' Transformer and TransformerFactory. Please help me
    <?xml version="1.0" encoding="UTF-8"?>
    <address>
    <addressID/>
    <streetNumber/>
    <addressLine1/>
    <addressLine2/>
    <addressLine3/>
    <city/>
    <zipCode/>
    <lastUpdatedUserID/>
    <deletedFlag/>
    <phoneNumber/>
    <country/>
    <state/>
    </address>

    I don't quite understand your question. You want to have the start tag of each element outputed or you want one root element start tag to be outputed?
    If it's the first case, try separating start and end tags from your elements instead of having them combined, i.e. do the following:
    replace
    <addressLine1/>by
    ]<addressLine1>
    </addressLine1>I don't know if this is the answer you expect, reply if not.

  • XML-Tag with own namespace

    Hi all,
    i have a scenario RFC-> XI -> SOAP-XML. But in SOAP-XML i have to use own namespace für each XML-Tag, e.g. <xyz:name>. Should i write a java mapping programe? Is there another way?
    regards,
    Fanglin

    I think you want to define namespace prefix for each tag. Use XMLANONYMIZERBean .  Refer this link and scn for the same discussion. You will see plenty of threads.
    http://help.sap.com/saphelp_nw04/helpdata/en/45/d169186a29570ae10000000a114a6b/content.htm

  • Generating xml tags with stored procedure

    Hi Friends,
    I have to create a xml report using procedure .the code is given here to generate xml tags.
    create or replace procedure sri_xml (errbuff out varchar2,
    retcode out number) as
    /* create cursor to fetch the records*/
    cursor c_emp is select empno,
    ename,
    deptno,
    sal,
    job
    from emp;
    begin
    /* first line of xml data should be "<? xml version = "0.1"?>" */
    fnd_file.put_line(fnd_file.output,'<?xml version = "1.0" ?>');
    fnd_file.put_line(fnd_file.output,'<per_emp1>');
    for c in c_emp loop
    /* for each record create a group tag <gemp_name> at start */
    fnd_file.put_line(fnd_file.output,'<G_EMP_NAME>');
    /*EMBEDD DATA BETWEEN XML TAGS */
    fnd_file.put_line(fnd_file.output,'<empno>' || c.empno || '</empno>');
    fnd_file.put_line(fnd_file.output,'<ename>' || c.ename || '</ename>');
    fnd_file.put_line(fnd_file.output,'<sal>' || c.sal || '</sal>');
    fnd_file.put_line(fnd_file.output,'</G_EMP_NAME>');
    end loop;
    fnd_file.put_line(fnd_file.output,'</per_emp1>');
    end;
    i run the procedure in the concurrent program with output mode as text and i got the xml tags as the out put. i have created the template using the data definition and registered them in the xml publisher administer but i am unable to get the out put when i run the concurrent request it is giving the message "AUTHENTICATION FAILED".
    please help me to solve the problem and to get the desired output with desired template.
    thanks in advance,
    siddam

    Hi Siddam,
    Please post your query on BI Publisher forum.
    There are number of folks who can resolve the issue u faced.
    Please go through the bi publisher developers guide and then design the report.
    I am not sure about the process ur following for report development...i think you have to create data defination and rtf layout and then attach it to oracle xml administrator responsibility.
    Ratnesh

  • Facing problem while removing XML tags which has been generated from SAP

    Hi All,
    I am facing problem in MII, while i trying to remove 1st 2 XML tags of XML as generated from SAP.
    Here is XML which has been generated from SAP
    u201C<?xml version="1.0"; encoding="UTF-8"?>
    <ZCIFSCHEDULE>
    <SCHEDULE>
    <MESSAGE_TYPE/>
    <SITE>A300</SITE>
    <SHOP_ORDER>2012020856</SHOP_ORDER>
    <QTY_TO_BUILD>6.000<;/QTY_TO_BUILD>
    <DATE_TIME>08-FEB-2012 20:57:21 +05:30</DATE_TIME>
    <OPERATION>PRS</OPERATION>
    <ITEM>IN-CT00228</ITEM>
    <DPICS_CODE>1229</DPICS_CODE>
    <REVISION/>
    <CYC_TIME_CURING/>
    <FLAG_AGING/>
    <AGING_MIN/>
    <PRODUCTION_VERSION/>
    <CYC_TIME_OC/>
    <CYC_TIME/>
    </SCHEDULE>
    </ZCIFSCHEDULE>u201D
    From above i want to remove 1st 2 tags and last one tag i.e.  u201C<?xml version="1.0"; encoding="UTF-8"?> , <ZCIFSCHEDULE> and last tag ZCIFSCHEDULE>u201D
    Its urgent!
    Did anyone done regarding this issues. Thanks in advance.
    Kind Regards,
    Praveen Reddy

    Hi Praveen,
    Are you trying to make the xml into a string?  I think if you remove the first tag, it will either automagically reappear or it will throw and error as being poorly formed xml. 
    In general, you can remove the nodes by the use of indexes.  Since you are operating at the root level, I am not sure how well it will work, but if your xml is in a property, you can reference the specific nodes by something like this:  myXML.Output{/*[1]} which if you put it in a tracer will display the contents of the first node (or blank if there are child nodes).  The node index can be dynamically set, but start with the simple hard coded one.  I would also start at the lowest child level to verify that it is working properly (a tracer will display the contents specified by the index).  You can also google xml indices (or indexes) and it will point to some other useful xml operators.
    I suggest that you play around with it and also work with the Link Types (hint: removeXML).
    Regards,
    Mike

  • Generating XML Tags in PLSQL using XMLELEMENT

    Hi All,
    I am trying to generate XML Tags using XMLELEMENT. Does anyone has an example for this. I have special characters in my DATA so the normal Concatenation does not work.........
    Thanks In Advance.

    try select xmlelement("ELEMENT_NAME",column)
    into var
    from dual;
    var must be defined as xmltype

  • Assign paragraph-styles to xml-tags correctly. How to?

    Hi,
    I want to assign xml-tags to existing paragraph styles in InDesign CS6 on a Mac 10.6.8. The xml itself is organized like this:
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <katalog>
    <artikel id="32434">
    <img href="/bilder/32434.tiff" />
    <artikeltextgruppe>
    <artikelmarke>DieselGabana</artikelmarke>
    <artikelheadline>Jeans ist super</artikelheadline>
    <artikeltext>Superjeans knallt rein.</artikeltext><artikelnummer>70238</artikelnummer>
    <artikelmaterial>100% Jeans</artikelmaterial>
    <artikelgroesse>Uni</artikelgroesse>
    <artikelfarbe>Uni</artikelfarbe>
    </artikeltextgruppe>
    </artikel>
    </katalog>
    By selecting the option "Assign formats per name to the tags" (translated from German) I wanted to generate the desired look. But if I start this all I get is the whole textblock of <artikeltextgruppe> assigned to 1 formatstyle. And besides that the whole content of <artikeltextgruppe> looks like one single paragraph without any structure (no linebreaks) The content though is correctly structured because I can highlight the value of e.g. <artikelmarke>separately by doubleclicking this tag in the structure-view.
    a) What can I do to assign the formats correctly AND to have correct linebreaks?
    b) If I drag my node <img href="/bilder/32434.tiff" /> iin the layout I get a message displayed to search again for the correct reference location. And that happens independently on using relative or absolute references (Although I need to use relative ones) What can I do here?
    thanks so much

    First, I would probably do a search and replace to remove the group element using a text editor (the <artikeltextgruppe> and </artikeltextgruppe> elements). They really are not needed.
    Second, I usually create my styles with the same names as the elements themselves. Then, after the XML is imported, I use the "map tags to styles" command from the Structure pane.
    I copied and pasted the single artikel element to create 4 records, added a varition of an image to each element record. Once the paragraph styles were mapped, your XML looked like this in a two column format (to get all 4 records on a page)...
    By default, ID will create a single line to a single line in the XML. So if you desire elements to be on their own line, the XML needs to be formatted that way. If you need different styling within a paragraph, you need to create character styles and alter the elements within an XML group and or paragraph and add the code in the XML accordingly or post process once inside of ID.
    I always need to take the XML I am given and reformat, move elements with the tree, change links to images, remove tabs and or spaces where I do not want them, tag for character styles, etc., to get close to how I want the initial format to be.
    Mike

  • Using a variable value in CDATA for generating an XML type in Oracle

    Hello,
    I have prepared a function given below where I have some input variables & I have to generate one XML with those input variables as tag attribute value:
    create or replace function NEW_PROJECT_DETAILS
    ( p_ReferenceId in varchar2 ,
    p_Project_No in varchar2,
    p_Project_Name in varchar2,
    p_Project_Desc in varchar2 ,
    p_Project_Type in varchar2,
    p_Project_Location in varchar2,
    p_Project_Status in varchar2 )
    return xmltype
    as
    payload xmltype;
    begin
    dbms_output.put_line('Payload Started');
    payload:= xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ProjectDetails>
    <RefID>'||p_ReferenceId||'</RefID>
    <ProjectNo>'||p_Project_No||'</ProjectNo>
    <ProjectName>'||p_Project_Name||'</ProjectName>
    <ProjectDesc>'||p_Project_Desc||'</ProjectDesc>
    <ProjectType>'||p_Project_Type||'</ProjectType>
    <ProjectLocation><![CDATA[p_Project_Location]]></ProjectLocation>
    /* <ProjectLocation>'||p_Project_Location||'</ProjectLocation> */
    <ProjectStatus>'||p_Project_Status||'</ProjectStatus>
    </ProjectDetails>');
    dbms_output.put_line('Payload Comp1');
    return payload;
    end;
    This procedure works absolutely fine.
    Now the problem which I am having is that the variable p_Project_Location has value like "6747:BBO&M SBV".
    Due to the '*&*' in that value I have to use CDATA. But i dont know how to pass this variable directly in the CDATA in the XML.
    Please help me with this asap.
    Thanks & Regards,
    Divya Aggarwal
    Edited by: 784414 on Dec 2, 2010 4:15 AM
    Edited by: 784414 on Dec 2, 2010 4:16 AM

    Hi,
    If you absolutely want to use a CDATA section, then :
    payload:= xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ProjectDetails>
    <RefID>'||p_ReferenceId||'</RefID>
    <ProjectNo>'||p_Project_No||'</ProjectNo>
    <ProjectName>'||p_Project_Name||'</ProjectName>
    <ProjectDesc>'||p_Project_Desc||'</ProjectDesc>
    <ProjectType>'||p_Project_Type||'</ProjectType>
    <ProjectLocation><![CDATA['||p_Project_Location||']]></ProjectLocation>
    <ProjectStatus>'||p_Project_Status||'</ProjectStatus>
    </ProjectDetails>');Alternatively, you can escape non valid characters with DBMS_XMLGEN.CONVERT, e.g. :
    payload:= xmltype('<?xml version="1.0" encoding="UTF-8"?>
    <ProjectDetails>
    <RefID>'||p_ReferenceId||'</RefID>
    <ProjectNo>'||p_Project_No||'</ProjectNo>
    <ProjectName>'||p_Project_Name||'</ProjectName>
    <ProjectDesc>'||p_Project_Desc||'</ProjectDesc>
    <ProjectType>'||p_Project_Type||'</ProjectType>
    <ProjectLocation>'||dbms_xmlgen.convert(p_Project_Location)||'</ProjectLocation>
    <ProjectStatus>'||p_Project_Status||'</ProjectStatus>
    </ProjectDetails>');which outputs :
    <?xml version="1.0" encoding="UTF-8"?>
    <ProjectDetails>
    <RefID>1</RefID>
    <ProjectNo>1</ProjectNo>
    <ProjectName>PRJ1</ProjectName>
    <ProjectDesc>This is project 1</ProjectDesc>
    <ProjectType>P</ProjectType>
    <ProjectLocation>6747:BBO&amp;M SBV</ProjectLocation>
    <ProjectStatus>S</ProjectStatus>
    </ProjectDetails>Any basic XML parser should then convert back escaped characters when processing the document.
    You can also use SQL/XML functions, which will take care of that automatically.
    For example :
    SELECT appendChildXML(
            XMLType('<?xml version="1.0" encoding="UTF-8"?><ProjectDetails/>'),
            XMLForest(
             '1'                 as "RefID",
             '1'                 as "ProjectNo",
             'PRJ1'              as "ProjectName",
             'This is project 1' as "ProjectDesc",
             'P'                 as "ProjectType",
             '6747:BBO&M SBV'    as "ProjectLocation",
             'S'                 as "ProjectStatus"
    FROM dual;or,
    SELECT appendChildXML(
            XMLType('<?xml version="1.0" encoding="UTF-8"?><ProjectDetails/>'),
            XMLForest(
             '1'                 as "RefID",
             '1'                 as "ProjectNo",
             'PRJ1'              as "ProjectName",
             'This is project 1' as "ProjectDesc",
             'P'                 as "ProjectType",
             XMLCData('6747:BBO&M SBV') as "ProjectLocation",
             'S'                 as "ProjectStatus"
    FROM dual;

  • Error for fetching long text in xml tag for xml publisher report

    My requirement is to fetch a large document which is in text format in XML output which can be printed in PDF format by using RTF method to generate PDF.But during XML ouput i got the following error-
    The XML page cannot be displayed
    Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh
    button, or try again later.
    The following tags were not closed: XXBG_EAMWRREP_V1, LIST_G_WO_ACTIVITY_CODE, G_WO_ACTIVITY_CODE, LIST_G_MEDIA_ID1,
    G_MEDIA...
    XXBG_EAMWRREP_V1 is the rdf and LIST_G_WO_ACTIVITY_CODE, G_WO_ACTIVITY_CODE, LIST_G_MEDIA_ID1, G_MEDIA are the groups name. In the group
    G_MEDIA i am fetching long_text from attahcment in application. In Database table the datatype of the text attachment is 'long' and there is a huge text
    data loaded in large data editor of that column. If the text data volume is small enough then there is no problem for fetching the xml output.
    If we change the output format as HTMl then there is no problem for fetching the output for long text but for xml output format we are unable to fetch the data
    in xml tag.
    One thing to mention the oracle report is the copy of Maintenance Work Order Detail Report. The seeded report is HTML format in 11i. The requirement is to make it in xml report.
    Please help.

    Hi,
    Actually clob datatype is not available in oracle report builder datatype lov. Could you pls tell the other ways of converting that to clob in oracle report...

  • Generating an XML Document from an internal table in ABAP

    Good day to all of you;
    With ABAP, in the R/3 system, I'm trying to figure out a way to accomplish the following:
    1) SELECT a set of Purchase Order data into an internal table.
    2) Generate an XML document, containing the above data, using a specific schema.
    I've been playing around with function module SAP_CONVERT_TO_XML_FORMAT which has the following interface:
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
          EXPORTING
          I_FIELD_SEPERATOR    = ''
          I_LINE_HEADER        = ''
            I_FILENAME           = v_fname
          I_APPL_KEEP          = ''
          I_XML_DOC_NAME      = v_docname
          IMPORTING
            PE_BIN_FILESIZE      = v_byte
          TABLES
            I_TAB_SAP_DATA       = i_SapData
          CHANGING
            I_TAB_CONVERTED_DATA = i_XMLData
          EXCEPTIONS
            CONVERSION_FAILED    = 1
            OTHERS               = 2.
    I'm uncertain as to whether or not the Export parameter, I_XML_DOC_NAME refers to some schema or definition and therefore have been excluding it.  In doing so, the generated XML document seems to use the field name/type information from my itab for the tags.
    If this function module requires an XML Document Name, how do I create one and where do I store it in R/3?  If this is not the recommended solution, is anyone familiar with a way to load an XML schema, retrieve some data then have SAP generate an XML document using the schema?
    Many thanks for any help available.
    T

    Hai Phillips
    Try with the following Code
    This program exports an internal table to an XML file.
    Report ZPRUEBA_MML_13 *
    Export an internal table to XML document *
    NO BORRAR ESTE CODIGO *
    REPORT ZPRUEBA_MML_13.
    PANTALLA SELECCION *
        PARAMETERS: GK_RUTA TYPE RLGRAP-FILENAME.
    PANTALLA SELECCION *
    TYPE TURNOS *
    TYPES: BEGIN OF TURNOS,
        LU LIKE T552A-TPR01,
        MA LIKE T552A-TPR01,
        MI LIKE T552A-TPR01,
        JU LIKE T552A-TPR01,
        VI LIKE T552A-TPR01,
        SA LIKE T552A-TPR01,
        DO LIKE T552A-TPR01,
    END OF TURNOS.
    TYPE TURNOS *
    TYPE SOCIO *
    TYPES: BEGIN OF SOCIO,
        NUMERO LIKE PERNR-PERNR,
        REPOSICION LIKE PA0050-ZAUVE,
        NOMBRE LIKE PA0002-VORNA,
        TURNOS TYPE TURNOS,
    END OF SOCIO.
    TYPE SOCIO *
    ESTRUCTURA ACCESOS *
    DATA: BEGIN OF ACCESOS OCCURS 0,
        SOCIO TYPE SOCIO,
    END OF ACCESOS.
    ESTRUCTURA ACCESOS *
    START OF SELECTION *
    START-OF-SELECTION.
        PERFORM LLENA_ACCESOS.
        PERFORM DESCARGA_XML.
    END-OF-SELECTION.
    END OF SELECTION *
    FORM LLENA_ACCESOS *
    FORM LLENA_ACCESOS.
    REFRESH ACCESOS.
    CLEAR ACCESOS.
    MOVE: '45050' TO ACCESOS-SOCIO-NUMERO,
                  'MOISES MORENO' TO ACCESOS-SOCIO-NOMBRE,
                  '0' TO ACCESOS-SOCIO-REPOSICION,
                  'T1' TO ACCESOS-SOCIO-TURNOS-LU,
                  'T2' TO ACCESOS-SOCIO-TURNOS-MA,
                  'T3' TO ACCESOS-SOCIO-TURNOS-MI,
                  'T4' TO ACCESOS-SOCIO-TURNOS-JU,
                  'T5' TO ACCESOS-SOCIO-TURNOS-VI,
                  'T6' TO ACCESOS-SOCIO-TURNOS-SA,
                  'T7' TO ACCESOS-SOCIO-TURNOS-DO.
    APPEND ACCESOS.
    CLEAR ACCESOS.
    MOVE: '45051' TO ACCESOS-SOCIO-NUMERO,
                  'RUTH PEÑA' TO ACCESOS-SOCIO-NOMBRE,
                  '0' TO ACCESOS-SOCIO-REPOSICION,
                  'T1' TO ACCESOS-SOCIO-TURNOS-LU,
                  'T2' TO ACCESOS-SOCIO-TURNOS-MA,
                  'T3' TO ACCESOS-SOCIO-TURNOS-MI,
                  'T4' TO ACCESOS-SOCIO-TURNOS-JU,
                  'T5' TO ACCESOS-SOCIO-TURNOS-VI,
                  'T6' TO ACCESOS-SOCIO-TURNOS-SA,
                  'T7' TO ACCESOS-SOCIO-TURNOS-DO.
    APPEND ACCESOS.
    ENDFORM.
    FORM LLENA_ACCESOS *
    FORM DESCARGA_XML *
    FORM DESCARGA_XML.
    DATA: L_DOM TYPE REF TO IF_IXML_ELEMENT,
                  M_DOCUMENT TYPE REF TO IF_IXML_DOCUMENT,
                  G_IXML TYPE REF TO IF_IXML,
                  W_STRING TYPE XSTRING,
                  W_SIZE TYPE I,
                  W_RESULT TYPE I,
                  W_LINE TYPE STRING,
                  IT_XML TYPE DCXMLLINES,
                  S_XML LIKE LINE OF IT_XML,
                  W_RC LIKE SY-SUBRC.
    DATA: XML TYPE DCXMLLINES.
    DATA: RC TYPE SY-SUBRC,
    BEGIN OF XML_TAB OCCURS 0,
                  D LIKE LINE OF XML,
    END OF XML_TAB.
    CLASS CL_IXML DEFINITION LOAD.
    G_IXML = CL_IXML=>CREATE( ).
    CHECK NOT G_IXML IS INITIAL.
    M_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
    CHECK NOT M_DOCUMENT IS INITIAL.
    WRITE: / 'Converting DATA TO DOM 1:'.
    CALL FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
                  NAME = 'ACCESOS'
                  DATAOBJECT = ACCESOS[]
    IMPORTING
                  DATA_AS_DOM = L_DOM
    CHANGING
                  DOCUMENT = M_DOCUMENT
    EXCEPTIONS
                  ILLEGAL_NAME = 1
                  OTHERS = 2.
    IF SY-SUBRC = 0.
                  WRITE 'Ok'.
    ELSE.
                  WRITE: 'Err =',
                  SY-SUBRC.
    ENDIF.
    CHECK NOT L_DOM IS INITIAL.
    W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
    IF W_RC IS INITIAL.
                  WRITE 'Ok'.
    ELSE.
                  WRITE: 'Err =',
                  W_RC.
    ENDIF.
    CALL FUNCTION 'SDIXML_DOM_TO_XML'
    EXPORTING
                  DOCUMENT = M_DOCUMENT
    IMPORTING
                  XML_AS_STRING = W_STRING
                  SIZE = W_SIZE
    TABLES
                  XML_AS_TABLE = IT_XML
    EXCEPTIONS
                  NO_DOCUMENT = 1
                  OTHERS = 2.
    IF SY-SUBRC = 0.
                  WRITE 'Ok'.
    ELSE.
                  WRITE: 'Err =',
                  SY-SUBRC.
    ENDIF.
    LOOP AT IT_XML INTO XML_TAB-D.
                  APPEND XML_TAB.
    ENDLOOP.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
                  BIN_FILESIZE = W_SIZE
                  FILENAME = GK_RUTA
                  FILETYPE = 'BIN'
    TABLES
                  DATA_TAB = XML_TAB
    EXCEPTIONS
                  OTHERS = 10.
    IF SY-SUBRC <> 0.
                  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.
    FORM DESCARGA_XML *
    Thanks & regards
    Sreenivasulu P

  • Conversion of text with xml tags to text without xml tags

    Hi all,
    We have a requirement wherein we have to discard xml tags in a text string.
    The scenario is that we have got the text from the fm READ_TEXT which contains xml tags also.
    we need to populate this text sans the xml tags  into the data segment of a iDOC.
    The text returned by the FM is " <s><<H>INVOICING INSTRUCTIONS:</><s> Invoices referencing a Boyne "
    Helpfull ans will be rewarded
    TIA

    Use the function module:
    SOTR_TAGS_REMOVE_FROM_STRING
    sorry for duplicate post:
    Check this thread:
    Need help getting rid of those <ASX:ABAP> tags from the generated XML file!
    Re: XI 2.0 Inbound message to XI has XML Tags Stripped out
    as well
    Regards,
    ravi

Maybe you are looking for

  • Problem with data not displaying in website

    Hello All,    I am having a problem with one of our applications. It is written in ColdFusion and uses SQL server. The problem that we are having is when we use the URL Http://bma.com (that is not actually the site name)  we cannot see all the data t

  • Can I use Apps from another apple ID?

    I bought my son an IPOD touch last christmas and didnt set up a new apple id. He is using my apple id as he was too young for an email at the time. Now he wants his own apple id as he wants to send messages etc. Can I set him up with a new apple id a

  • Console bouncing erratically (earlier post marked answered prematurely)

    Sorry about this apparent double post. Asked earlier why Console, opened, and set to bounce, wasn't bouncing. I don't want to add this to the earlier post, since, as it's marked answered, I don't think anyone will notice it there any more. http://dis

  • Help!! Disconnect Problems

    I have a linksys wrt54g wireless router. I have no problems connecting with the internet with the router, but I lose the connection a lot. Sometimes it is several times in an hour, sometimes maybe only once. Most times it is only for a minute, but it

  • Content requires HDCP

    I have an older TV that does not have an HDMI port.  I purchased an HDMI to Composite converter (Bytecc) and hooked it up to stream Apple TV.  It plays some content, but when I try Netflix or HBOGO I get the following error message-- "This content re