Query to generate an xml output hierarchically
Hi I need to write a sql query to generate an xml hierarchically for a tree menu. I have one self-joined table that holds menu hierarchy.
Following is a sample data in a table.
MenuID MenuName ParentID href
1 File
12 Open 1 Open.jsp
11 New 1
21 Program 11
61 Program2 11 Program2.jsp
31 Blank 21 Blank.jsp
2 View
22 Printer
28 Printer2 22
30 Printer3 28 test.jsp
23 Doc Doc.jsp
4 Tools Tools.jsp
5 Win 1 Win.jspFollowing is the sample output want to generate:
<?xml version = '1.0' encoding = 'windows-1252'?>
<menus>
<menu name="File" id="1">
<menu name="Open" id="12" href="Open.jsp"/>
<menu name="New" id="11">
<menu name="Program" id="21">
<menu name="Blank" id="31" href="Blank.jsp"/>
</menu>
<menu name="Program2" id="61" href="Program2.jsp"/>
</menu>
<menu name="Win" id="5" href="Win.jsp"/>
</menu>
<menu name="View" id="2">
<menu name="Printer" id="22">
<menu name="Printer2" id="28">
<menu name="Printer3" id="30" href="test.jsp">
</menu>
</menu>
</menu>
<menu name="Doc" id="3" href="Doc.jsp"/>
<menu name="Tools" id="4" href="Tools.jsp"/>
</menus>Thanks
You can use SYS_CONNECT_BY_PATH to get the complete hierarchical path to an object, and then order by that. Here is an example:
with menutbl as
(select 1 as MenuId,'File' as MenuName, null as ParentId, null as href from dual
union all
select 12,'Open',1,'Open.jsp' from dual
union all
select 11,'New',1,null from dual
union all
select 21,'Program',11,null from dual
union all
select 61,'Program2',11,'Program2.jsp' from dual
union all
select 31,'Blank',21,'Blank.jsp' from dual
union all
select 2,'View',null,null from dual
union all
select 22,'Printer',null,null from dual
union all
select 28,'Printer2',22,null from dual
union all
select 30,'Printer3',28,'test.jsp' from dual
union all
select 23,'Doc',null,'Doc.jsp' from dual
union all
select 4,'Tools',null,'Tools.jsp' from dual
union all
select 5,'Win',1,'Win.jsp' from dual)
select * from (
select menutbl.*, SYS_CONNECT_BY_PATH(MenuId, '/') as path from menutbl start with parentid is null connect by
NOCYCLE PRIOR MenuId = ParentId) order by path;this prints
1 File /1
11 New 1 /1/11
21 Program 11 /1/11/21
31 Blank 21 Blank.jsp /1/11/21/31
61 Program2 11 Program2.jsp /1/11/61
12 Open 1 Open.jsp /1/12
5 Win 1 Win.jsp /1/5
2 View /2
22 Printer /22
28 Printer2 22 /22/28
30 Printer3 28 test.jsp /22/28/30
23 Doc Doc.jsp /23
4 Tools Tools.jsp /4I guess that you can take over from here and add html elements around the text...
gojko adzic
http://gojko.net
Similar Messages
-
SQL query to generate Nested XML
Hello,
I use Oracle 11g R2 SOE....
I have two main tables
COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number)
COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2)
Please, note the following has nothing to do with my problem:
CONTENT and MIMETYPE columns. Also, the lookup tables: PROJECTS , COM_TYPE
In APEX ( Application Express ) we can expose a report as RESTful web service in XML format:
I am using this query to generate the XML 1 feed, but I need to tweak the query to generate XML 2 feed.
Is it possible, how to do it ???
Select
"COM"."COM_ID" as "COM_ID",
"COM"."COM_SIZE" as "SIZE",
"PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
"COM_TYPES"."COM_TYPE" as "COM_TYPE",
'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
FROM
COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
on IMG.COM_ID = COM.COM_ID
inner join "PROJECTS" "PROJECTS"
on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
inner join "COM_TYPE_LOOKUP" "COM_TYPES"
on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
WHERE
COM.COM_ID < 80 order by 1h1. XML 1
h2. Please look only at <COM_ID> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
</ROW>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</ROW>
</ROWSET>---------------------------
h1. XML 2
h2. Please look only at <COM_ID> and <Images> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</Images>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</Images>
</ROW>
</ROWSET>Hi, Fateh
One possible way is to use XML functions to create your XML.
Using XML functions you can do the IMAGES as an XMLAGG subquery rather than join to the image table.
Here's an example using SCOTT schema:
SQL> select xmlelement(
2 "ROWSET"
3 , xmlagg(
4 xmlelement(
5 "ROW"
6 , xmlforest(
7 d.deptno as "ID"
8 , d.dname as "NAME"
9 , (
10 select xmlagg(
11 xmlelement(
12 "ImgUrl"
13 , 'http://the.server.com/'||e.empno
14 )
15 order by e.empno
16 )
17 from scott.emp e
18 where e.deptno = d.deptno
19 ) as "Images"
20 )
21 )
22 order by d.deptno
23 )
24 ) the_xml
25 from scott.dept d
26 /* joins to the other tables EXCEPT image table */
27 /
THE_XML
<ROWSET><ROW><ID>10</ID><NAME>ACCOUNTING</NAME><Images><ImgUrl>http://the.serverThat output is an XMLTYPE column (think of it as a CLOB with added functionality ;-) )
My SQL*PLUS cuts the output, but believe me, it is all there.
Just to show it, here's the same example wrapped in an XMLSERIALIZE function to pretty-print the XML:
SQL> select xmlserialize(
2 content
3 xmlelement(
4 "ROWSET"
5 , xmlagg(
6 xmlelement(
7 "ROW"
8 , xmlforest(
9 d.deptno as "ID"
10 , d.dname as "NAME"
11 , (
12 select xmlagg(
13 xmlelement(
14 "ImgUrl"
15 , 'http://the.server.com/'||e.empno
16 )
17 order by e.empno
18 )
19 from scott.emp e
20 where e.deptno = d.deptno
21 ) as "Images"
22 )
23 )
24 order by d.deptno
25 )
26 )
27 as varchar2(4000)
28 indent size=2
29 ) the_xml
30 from scott.dept d
31 /* joins to the other tables EXCEPT image table */
32 /
THE_XML
<ROWSET>
<ROW>
<ID>10</ID>
<NAME>ACCOUNTING</NAME>
<Images>
<ImgUrl>http://the.server.com/7782</ImgUrl>
<ImgUrl>http://the.server.com/7839</ImgUrl>
<ImgUrl>http://the.server.com/7934</ImgUrl>
</Images>
</ROW>
<ROW>
<ID>20</ID>
<NAME>RESEARCH</NAME>
<Images>
<ImgUrl>http://the.server.com/7369</ImgUrl>
<ImgUrl>http://the.server.com/7566</ImgUrl>
<ImgUrl>http://the.server.com/7788</ImgUrl>
<ImgUrl>http://the.server.com/7876</ImgUrl>
<ImgUrl>http://the.server.com/7902</ImgUrl>
</Images>
</ROW>
<ROW>
<ID>30</ID>
<NAME>SALES</NAME>
<Images>
<ImgUrl>http://the.server.com/7499</ImgUrl>
<ImgUrl>http://the.server.com/7521</ImgUrl>
<ImgUrl>http://the.server.com/7654</ImgUrl>
<ImgUrl>http://the.server.com/7698</ImgUrl>
<ImgUrl>http://the.server.com/7844</ImgUrl>
<ImgUrl>http://the.server.com/7900</ImgUrl>
</Images>
</ROW>
<ROW>
<ID>40</ID>
<NAME>OPERATIONS</NAME>
</ROW>
</ROWSET>For a webservice you do not need to pretty-print the XML that is returned by the webservice.
I do not know APEX, so I do not know if APEX supports exposing an allready built piece of XML rather than exposing a query result.
But my guess is that it should do it very nicely if you query an XMLTYPE datatype (that is - use the first of my examples rather than the pretty-printed one.)
If you can't get APEX to do it this way, then I suggest you try asking in the APEX forum rather than the SQL forum ;-) -
Query to generate Nested XML feed
Hello,
I use Oracle 11g R2 SOE....
I have two main tables
COMMERCIALS_PROPERTIES (com_id number PK , com_size number, project_id number, com_type number)
COM_PHOTOS (ID number PK , com_id number FK, content blob, mimetype varchar2)
Please, note the following has nothing to do with my problem:
CONTENT and MIMETYPE columns. Also, the lookup tables: PROJECTS , COM_TYPE
I Exposed a report as RESTful web service in XML format:
I am using this query to generate the XML 1 feed, but I need to tweak the query to generate XML 2 feed.
Is it possible, how to do it ???
Select
"COM"."COM_ID" as "COM_ID",
"COM"."COM_SIZE" as "SIZE",
"PROJECTS"."PROJECT_NAME_EN" as "PROJECT",
"COM_TYPES"."COM_TYPE" as "COM_TYPE",
'http://fam-erp.com/apex/erp/fateh/'||IMG.ID as "ImgURL"
FROM
COM_PHOTOS IMG inner join COMMERCIALS_PROPERTIES "COM"
on IMG.COM_ID = COM.COM_ID
inner join "PROJECTS" "PROJECTS"
on "PROJECTS"."PROJECT_ID"="COM"."PROJECT_ID"
inner join "COM_TYPE_LOOKUP" "COM_TYPES"
on "COM_TYPES"."TYPE_ID"="COM"."COM_TYPE"
WHERE
COM.COM_ID < 80 order by 1h1. XML 1
h2. Please look only at <COM_ID> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
</ROW>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</ROW>
</ROWSET>---------------------------
h1. XML 2
h2. Please look only at <COM_ID> and <Images> and <ImgURL>
<ROWSET>
<ROW>
<COM_ID>77</COM_ID>
<SIZE>842</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1410</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1412</ImgURL>
</Images>
</ROW>
<ROW>
<COM_ID>78</COM_ID>
<SIZE>756</SIZE>
<PROJECT>Bayswater Tower</PROJECT>
<COM_TYPE>Office</COM_TYPE>
<Images>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1425</ImgURL>
<ImgURL>http://fam-erp.com/apex/erp/fateh/1429</ImgURL>
</Images>
</ROW>
</ROWSET>Hello,
I see, I found another solution, but come across another problem that is the web service should get Data from more than one table. I have this procedure, and I would like to *"UNION" its* Select Statement with another Select Statement:
declare
v_xml clob;
v_retval clob := '<?xml version="1.0" encoding="iso-8859-1"?>';
v_blob blob;
begin
select
xmlelement(
"LISTINGS",
xmlagg(
xmlelement(
"LISTING",
xmlforest(
'RS-'||R."RES_ID" as "Property_Ref_No",
"UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
'Sale' as "Ad_Type",
'Dubai' as "State",
L.LOCATION_NAME_EN AS "Community",
"PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
"RES_SALE"."ASKING_PRICE" as "Price",
' ' as "Frequency",
ST."SUB_TYPE" as "Unit_Model",
R."RES_SIZE" as "Unit_Builtup_Area",
R.BEDS as "Bedrooms",
R.bath as "No_of_Bathrooms",
"RES_SALE"."AD_TITLE" as "Property_Title",
RES_SALE.DESCRIPTION as "Web_Remarks",
to_char("RES_SALE"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
R.VIDEO as "Web_Tour",
select xmlagg(
xmlforest(
'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
FROM
IMAGES IMG
WHERE IMG.RES_ID = R.RES_ID ) Images )))).getclobval()
into v_xml
FROM
"RES_SALE" "RES_SALE"
inner join
RES R on (R."RES_ID"="RES_SALE"."RES_ID")
inner join
"UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_SALE"."RES_STATUS")
inner join
"PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
inner join
"UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
inner join
"RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
INNER JOIN
COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
INNER JOIN
LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
WHERE "RES_SALE".RES_status IN (5,8) AND "RES_SALE".LIVE = 'Y' AND "RES_SALE".DESCRIPTION IS NOT NULL
dbms_lob.append(v_retval,v_xml);
OWA_UTIL.Mime_Header('text/xml');
htp.p('Content-length: ' || to_char(dbms_lob.getlength(v_retval)));
htp.p('Content-Disposition: inline; filename="Just.xml"');
owa_util.http_header_close;
v_blob := wwv_flow_utilities.clob_to_blob(v_retval);
wpg_docload.download_file(v_blob);
end; h1. Select Statement that is needed to be "UNION-ED" with the Select Statement of the previous procedure:
select
xmlelement(
"LISTINGS",
xmlagg(
xmlelement(
"LISTING",
xmlforest(
'RR-'||R."RES_ID" as "Property_Ref_No",
"UNIT_TYPE_LOOKUP"."UNIT_TYPE" as "Unit_Type",
'Rent' as "Ad_Type",
'Dubai' as "State",
L.LOCATION_NAME_EN AS "Community",
"PROJECTS"."PROJECT_NAME_EN" as "Property_Name",
"RES_RENT"."ASKING_PRICE" as "Price",
' ' as "Frequency",
ST."SUB_TYPE" as "Unit_Model",
R."RES_SIZE" as "Unit_Builtup_Area",
R.BEDS as "Bedrooms",
R.bath as "No_of_Bathrooms",
"RES_RENT"."AD_TITLE" as "Property_Title",
"RES_RENT".DESCRIPTION as "Web_Remarks",
to_char("RES_RENT"."UPDATED_ON",'YYYY-MM-DD HH:MI:SSPM') as "Last_Updated",
R.VIDEO as "Web_Tour",
select xmlagg(
xmlforest(
'http://thevillaproject.com/apex/erp/IMAGES/'||IMG.ID AS "ImageUrl"
FROM
IMAGES IMG
WHERE IMG.RES_ID = R.RES_ID ) Images ))))
FROM
"RES_RENT" "RES_RENT"
inner join
RES R on (R."RES_ID"="RES_RENT"."RES_ID")
inner join
"UNIT_STATUS_LOOKUP" on (UNIT_STATUS_LOOKUP.status_id = "RES_RENT"."RES_STATUS")
inner join
"PROJECTS" "PROJECTS" on ("PROJECTS"."PROJECT_ID"=R."PROJECT_ID")
inner join
"UNIT_TYPE_LOOKUP" "UNIT_TYPE_LOOKUP" on ("UNIT_TYPE_LOOKUP"."TYPE_ID"=R."RES_TYPE")
inner join
"RES_SUB_TYPE_LOOKUP" ST on (ST."SUB_TYPE_ID"=R."SUB_TYPE")
INNER JOIN
COMPLEX_LOOKUP CL ON (CL.COMPLEX_ID = "PROJECTS".COMPLEX_ID)
INNER JOIN
LOCATIONS L ON (L.LOCATION_ID = CL.LOCATION_ID)
WHERE "RES_RENT".RES_status IN (5,8) AND "RES_RENT".LIVE = 'Y' AND "RES_RENT".DESCRIPTION IS NOT NULL -
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. -
How to generate as XML output from Oracle Apps 11
Hi Anyone has the experience to generate the output from Oracle Apps 11 as XML file? Database is 8.1.7, Oracle Apps 11. The concurrent program can be written in PL/SQL or can report 2.5 generate the output as XML?
The scenario is:
1) Run a concurrent program in Oracle Apps 11
2) Output generated is XML (.xml)
Regards.This forum is for Oracle XML DB features. XML DB is only available as of database 9iR2.
You may be better off in legacy XML Features forum...
PL/SQL XML Programming -
Easiest and/or best methods for generating XML output (not with a report)
Hi, several of our EBS customers (11.5.10) are converting their PDF reports to use XML/BI publisher to produce output. The data stream comes from a report that generates the XML output, and then the XML template is applied. This works great ... no problems, etc. From what I have read, however, Oracle intends to treat the traditional Forms and Reports Developers as legacy tools (although still supporting them, of course).
My question is if I wanted to ditch using Reports to generate XML output, what, in your opinion or in your current usage, is the easiest way of getting this data? In Reports, the data modeler is excellent in providing a method to write your queries, split them into different repeating groups, write formula and summary columns, link multiple queries, etc, etc. If one were to become Reports Developer free, what comparable tools are available to take its place? I would expect this tool to handle a mix of GUI and coding like the Reports data modeler. Please note that I'm not looking for an EBS-specific solution -- say for a custom application using regular Oracle 10g DB and iAS, with BI Publisher for reporting.
Thanks for your feedback,
RyanWhat I'm looking for is to not use Oracle Reports to generate the XML data output since Oracle's statement of direction is pushing BI Publisher rather than Oracle Reports as the preferred tool for reporting. That said, the data modeler in Reports provides a very flexible tool to construct and link multiple queries and to manipulate the queries into several levels of a master/detail relationship. Further, the mix of GUI and coding makes setting up the data model a lot more efficient. What I'm looking for (and I don't know if anything exists) is something comparable that can be used to generate XML output from the DB -- the idea being that I wouldn't use legacy tools, like Reports, for this task. I hope that is clearer.
Really, another way of answering my question is, aside from Reports and the APIs mentioned so far, what are my fellow developers using, if anything, to extract XML data in a way that handles the features i list above? -
Generate XML output using DBMS_XMLGEN.getxmltype and not from rdf
Hi,
I have a requirement to display output from a particular table in XL format. Out of all the known possible options, I am planning to use the XML publisher to generate XL output.
For the data source, instead of using the conventional way of creating XML data using rdf,I am planning to use DBMS_XMLGEN.getxmltype pl/sql procedure to generate the XML output. And from the output, call the template to generate the required Excel output.
Now, I am using the following code to generate XML output but am not sure how to proceed from here. I need to first print the XML data in the FND Output file after which I was planning to call the 'XML Report Publisher' (XDOREPPB) program and use the current request id to get the excel output but I am not able to find the way to print the XML data in the output file as:
fnd_file.put_line (fnd_file.output, l_xml_type); - is throwing an error as l_xml_type is an XML data output.
PROCEDURE xml_main (
errbuf OUT VARCHAR2
,retcode OUT VARCHAR2
,p_project_from IN VARCHAR2
,p_project_to IN VARCHAR2
AS
l_xml_type XMLTYPE;
BEGIN
SELECT DBMS_XMLGEN.getxmltype
('SELECT fnd_global.conc_request_id
,TO_CHAR (segment1)
,to_char(start_date,''MM/DD/RRRR'')
,to_char(xxmcc_project_details_pkg.current_profit_projection
(project_id),''999,999,990.90'')
,to_char(xxmcc_project_details_pkg.cost_to_date (project_id),''999,999,990.90'')
,''1''
FROM pa_projects_all
WHERE segment1 BETWEEN NVL (p_project_from, segment1)
AND NVL (p_project_to, segment1)')
INTO l_xml_type
FROM DUAL;
fnd_file.put_line (fnd_file.output, l_xml_type);
END xml_main;
Can anyone point me as to how to publish XML output using a PL/SQL procedure (DBMS_XMLGEN.getxmltype)
Thanks.Pl see if the example included in this presentation helps http://www.oracle.com/technology/products/applications/Events/OOW-2006/EBS/S281401_Sridhar_Bogelli.pdf
Also, you do not need to explicitly call XDOREPPB in later versions of XML Publisher. If you set up everything correctly (as described in the presentation above and the link below) the Output Post Processor is called automatically after the XML file is generated successfully.
Another excellent tutorial is at http://www.oracle.com/technology/obe/fusion_middleware/fusion/bi/xmlp_ebiz/index.html
HTH
Srini -
Unable to generate the XML file through SQL script. getting error PLS-00306
I am fetching the data from cursor and generating the xml output I am getting the below error.
When I have checked the cursor query it is fetching the data in to single column.
Input truncated to 1 characters
Enter value for 7: EXEC FND_CONC_STAT.COLLECT;
DBMS_LOB.append (tmp_file, r.core_xml);
ERROR at line 95:
ORA-06550: line 95, column 7:
PLS-00306: wrong number or types of arguments in call to 'APPEND'
ORA-06550: line 95, column 7:
PL/SQL: Statement ignoredHi Alex,
thanks for the responce..
i have fixed the issue
i have used XMLAttributes to get the value
SELECT XMLELEMENT (
NAME "TranACK",
XMLAttributes ('1' as "TranNum",
(select distinct to_char(SYSDATE,'yyyy-mm-dd')
from DUAL) as "PrcDate"),
XMLFOREST (
a.PAYMENT_ID AS "PmtID"),
XMLFOREST (
a.ACK_TRANSACTION_RECEIVER AS "Name1"),
XMLFOREST (
to_char(a.VALUE_DATE,'yyyy-mm-dd') as "ValueDate" ),
XMLFOREST (
a.PAYMENT_AMOUNT AS "CurAmt"),
XMLFOREST (
a.CURRENCY_CODE AS "CurCode")
).getclobval ()
AS line_xml
FROM XXWAP_PAYMENT_LINE_TBL a
where a.PAYMENT_BATCH_ID=P_batch_id; -
Generating structured XML file based on relational data base
Hi,
I need to use XML DB to generate a structured XML file based on the relational oracle database. I start by using Oracle default table, emp,
Here is EMP data,
EMPNO ENAME DEPNO SAL
123.00 E1 20.00 1,000.00
124.00 E2 20.00 2,000.00
125.00 E3 20.00 2,000.00
126.00 E4 30.00 3,000.00
127.00 E5 30.00 3,000.00
128.00 E6 30.00 4,000.00
129.00 E7 40.00 7,000.00
I used this SQL statement to generate an XML output,
select XMLElement ("Department",
XMLAttributes(deptno as "DEPARTMENTNO"),
XMLElement("EmployeeName", ename),
XMLElement("Salary", sal)
) "Result"
from
emp
where
deptno=20
The result was
<Department DEPARTMENTNO="20">
<EmployeeName>E1</EmployeeName>
<Salary>1000</Salary>
</Department>
<Department DEPARTMENTNO="20">
<EmployeeName>E2</EmployeeName>
<Salary>2000</Salary>
</Department>
<Department DEPARTMENTNO="20">
<EmployeeName>E3</EmployeeName>
<Salary>2000</Salary>
</Department>
but I need this structure instead,
<Department DEPARTMENTNO="20">
<EmployeeName>E1</EmployeeName>
<Salary>1000</Salary>
<EmployeeName>E2</EmployeeName>
<Salary>2000</Salary>
<EmployeeName>E3</EmployeeName>
<Salary>2000</Salary>
</Department>
Could you guide me how I can generate this kind of structure like master-detail structure and which document you recommend to obtain this point.
Thanks,
ShivaHi,
If you want to write an xml into file, I think you should use PL/SQL.
Is it even possible to spool output into file without the query itself?
doen't show me a proper xml fileTo get well-formed xml, you also have to make a root element.
If you want <?xml version="1.0"?> also then use xmlroot(), but I haven't figure out
how to specify the encoding.
SQL> WITH xtab AS(SELECT 'E1' ename,20 depno,1000 sal FROM dual
2 UNION ALL
3 SELECT 'E2',20,2000 FROM dual
4 UNION ALL
5 SELECT 'E3',40,3000 FROM dual
6 UNION ALL
7 SELECT 'E4',30,4000 FROM dual)
8 SELECT XMLRoot(XMLElement("Company",XMLAgg(XMLElement("Department",
9 XMLattributes(depno as "DEPARTMENTNO"),
10 XMLAgg(XMLForest(
11 ename AS "EmployeeName",
12 sal AS "Salary"))))),version '1.0') company_xml
13 FROM xtab
14 GROUP BY depno;
COMPANY_XML
<?xml version="1.0"?>
<Company>
<Department DEPARTMENTNO="20">
<EmployeeName>E1</EmployeeName>
<Salary>1000</Salary>
<EmployeeName>E2</EmployeeName>
<Salary>2000</Salary>
</Department>
<Department DEPARTMENTNO="30">
<EmployeeName>E4</EmployeeName>
<Salary>4000</Salary>
</Department>
<Department DEPARTMENTNO="40">
<EmployeeName>E3</EmployeeName>
<Salary>3000</Salary>
</Department>
</Company>
[pre] -
How to calculate number of data records in a XML output file
Hi,
After generating a XML output file from Oracle Reports, I want to calculate number of records in the XML file. Is it possible? Specifically, I want to calculate number of records for a group variable ( organization_id, which I use for bursting).
Thanks for the help.Thanks BIPuser. It is useful for me.
I can use this xsl function within the template. However, I'm also looking to print this in the concurrent request log file. So, outside of rtf template, id there any PL/SQL based XML functions I can use to count the number of records.
Thanks. -
Controlling XML output Livecycle Designer 8.0
Hello.
I am new to XML and somewhat new to LiveCycle Designer, however I have acclimated rather well.
Here is what I want to do:
1) Create a PDF fill-in-form (including various fields...text, numeric, radio buttons, and some FormCalc functions)
2) Create a Submit button that emails an XML file to the form administrator
3) Use MS Excel to import XML files into pre-mapped fields
Basically, I do not have server database support, and this is the best workaround (and most functional) I could come up with.
After mapping fields in Excel, I exported the *.xsd and created a new data connection within LiveCycle. Then, I linked the schema fields with the bindings - corrected any errors, and have tested the form (form1). I made the submit button - that's all good, too. When I import the XML into Excel - that's where I have a problem, and it's not an issue with Excel to my knowledge, but rather how the form generates the XML output.
For example, I have 25 fields that will be outputted via XML. My PDF form consists of 4 pages (8.5" x 11"). When I created the form and got to the end of the page, I "inserted new page" and went on my merry way. When I import the XML, Excel properly maps the fields, however, it does not import the info to a single row. What I have discovered is that since my PDF form consists of 4 pages (each bound to "sheet[*]"), the XML output looks like the following:
Example of the XML output from my form:
<form1>
<sheet>
<submissionID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>743</submissionID>
<reviewerID xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>234</reviewerID>
<date xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>24/01/2008</date>
</sheet>
<sheet>
<tag1>input</tag1>
<tag2>input</tag2>
</sheet>
</form1>
Wherever there is a "<form>" tag (hence a new page in my PDF document), Excel puts that data on a new column. All fields within form1 are imported and mapped to the correct field, however importing a single XML file will occur on 4 rows.
I bound each "page" as "sheet[*]" mostly because that is the only way I knew how to use FormCalc to do calculations from fields that occur at different places throughout the document.
So, I have tried to be as clear as possible, and would like suggestions/help as how to control the XML output from a LiveCycle document. If I am to modify the outputted XML and remove the multiple instances of <sheet> and </sheet> then Excel imports the data just fine and on a single row.
I would love some help on this rather specific problem. I guess it's a very basic issue that someone with experience could help.
Thank you so much!!
JimI have a vital form that clients fill out, which is passed to many people in the company along the workflow. The form is a Planner and we have in the following PDF, Word Doc..
Well before, the Planner.pdf was originally created in Word, since most people have access to Word.. but evolved to a PDF form created from the Word Doc via Adobe LiveCycle Designer 8.0 w/ User Rights enabled so that the form could be filled out and saved using Adobe Reader.. which was a step better than Word.. being that it is free. But this needed to be easier and more to the point b/c some clients don't particularly like installing the latest version of Reader, even if you provide them the link. Nor do they like saving the form, filling the form, and attaching the form to send back.
My goal is to have the client fill an HTML version of the form, submit and be done with it, but everyone in the workflow be able to easily receive the filled Planner as a PDF form.
So some months ago I ran into this post Chris Trip, "Populate Livecycle PDF from mySQL database using PHP" #8, 22 Sep 2007 4:37 pm
which uses the command line Win32 pdftk.exe to merge an FDF file into an existing PDF on the remote server, and serve this to whoever.
My problem was with shared hosting and having the ability to use the Win32 pdftk.exe along with PHP which is predominantly used on Linux boxes. And we used a Linux box.
so i created the following unorthodox method, which a client fills the HTML version of the Planner, all field values are INSERTED into a table in MySQL DB, I and all filled planners that have been filled by clients to date can be viewed from a repository page where an XML file is served up of the corresponding client, but someone would have to have Acrobat Professional, to import the form data from the XML file into a blank form.. altoughh this is simple for me.. I have the PHP file already created so that when a Planner is filled and client submits. >> the an email is sent to me with a table row from the repository of the client name, #, email, and a link to d-load the XML file,
But I also have the PHP files created so that the Planner can be sent to by email to various people in the workflow with certain fileds ommitted they they do not need to see, but instead of the XML file beiong served up i need the filled PDF Planner to be served.
I can do this locally with ease on a testing server, but I am currently trying to use another host that uses cross-platform compatibility so i can use PHP and the pdftk.exe to achieve this, as that is why I am having to serve up an XML file b/c we use a Linux server for our website, and cant execute the exe.
Now that I am testing the other server (cross-platform host), just to use them to do the PDF handling (and it's only $5 per month) I am having problems with getting READ, WRITE, EXECUTE permissions..
Si guess a good question to ask is can PHP do the same procedure as the pdftk.exe, and i can eleminate it.
or how in the heck can i get this data from the DB into a blank PDF form, like i have described??
here are some link to reference
Populating a LiveCycle PDF with PHP and MySQL
http://www.andrewheiss.com/Tutorials?page=LiveCycle_PDFs_and_MySQL
HTML form that passed data into a PDF
http://www.mactech.com/articles/mactech/Vol.20/20.11/FillOnlinePDFFormsUsingHTML/index.htm l
and an example
http://accesspdf.com/html_pdf_form/ -
Hi All,
Is there any function module in ABAP to generate an xml structure?
I want to generate an xml output in a string for the input structure (internal table)
Thanks
RickyHi ricky,
1. itab --- > xml
xml ---> itab.
2. This program will do both.
(just copy paste in new program)
3.
REPORT abc.
DATA
DATA : t001 LIKE TABLE OF t001 WITH HEADER LINE.
DATA : BEGIN OF itab OCCURS 0,
a(100) TYPE c,
END OF itab.
DATA: xml_out TYPE string .
DATA : BEGIN OF upl OCCURS 0,
f(255) TYPE c,
END OF upl.
DATA: xmlupl TYPE string .
FIRST PHASE
FIRST PHASE
FIRST PHASE
Fetch Data
SELECT * FROM t001 INTO TABLE t001.
XML
CALL TRANSFORMATION ('ID')
SOURCE tab = t001[]
RESULT XML xml_out.
CALL FUNCTION 'SCMS_STRING_TO_FTEXT'
EXPORTING
TEXT = xml_out
IMPORTING
LENGTH =
TABLES
FTEXT_TAB = itab.
Download
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = 'BIN'
filename = 'd:\xx.xml'
TABLES
data_tab = itab.
SECOND PHASE
SECOND PHASE
SECOND PHASE
BREAK-POINT.
REFRESH t001.
CLEAR t001.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:\XX.XML'
filetype = 'BIN'
TABLES
data_tab = upl.
LOOP AT upl.
CONCATENATE xmlupl upl-f INTO xmlupl.
ENDLOOP.
XML
CALL TRANSFORMATION ('ID')
SOURCE XML xmlupl
RESULT tab = t001[]
BREAK-POINT.
regards,
amit m. -
Hi Folks,
We are working on a Standalone SRM 5.0 system.
We are in the process of implementing Self Service Procurement scenario. One of the requirement is to send to an output (XML) of the Confirmation to a satellite WM system.
Was wondering if anyone has worked on such a scenario, if yes please throw some light as to how to generate an XML output after confirmation is posted in SRM.
Any help on is highly appreciated.
Thanks,
AVDid you tried to config "Define Actions for Document Output" option in SPRO.
Regards, IA -
Automatic XML output generation
i am trying to generate automatic xml output for a report. report dsnt take any parameters. i have written a xml definition
<report name="XML Report date spec GRFS03" DTDVersion="1.0">
<layout>
<section name="main">
<groupLeft name="G_LOC_CODE" >
<group>
<field name="LOC_CODE" source="loc_code"/>
<field name="QTTY" source="qty"/>
<field name="STK_NO" source="stk_no"/>
<field name="UNIT_COST" source="unit_cost"/>
<field name="USER_CODE" source="user_code"/>
</group>
</groupLeft>
</section>
</layout>
<customize>
<object name=”Gary D” type=”Report”>
//<properties>
//<property name=”beforeReportType”>File</property>
//<property name=”beforeReportValue”>C:\xmlreport.html
//</property>
</object>
</customize>
</report>
i have used SRW.APPLY_DEFINITION(xml_report.xml) for runtime customization but when i run report i get error : REP-6106: error in XML report definition at line 3 in 'xml_report.xml'
Root element name must match the DOCTYPE name.
can anyone suggest a solution to this?JDOM has an XMLOutputter.
DOM Level 3 allegedly supports outputting from the DOM itself.
However if you don't want to use JDOM, and you don't have access to DOM Level 3, there is a way to do it using transformers. I'm not sure if this is a trick or whether it's considered the standard way to do it.
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
Document dom; // this is what you want outputted
OutputStream stream; // this is where you want it outputted
Transformer identity = TransformerFactory.newInstance().newTransformer();
identity.transform(new DOMSource(dom), new StreamResult(stream));Note that it's not actually much code if you keep the identity transform around for reuse. JDOM's approach is a lot simpler though. :-) -
XML output with multiple tags in one line
I have not done much XML exporting with SQL. Previously I had just been ending my SQL queries with
FOR XML RAW ('Company'), ROOT ('Companies'), ELEMENTS;
and it formatted my query nicely in an XML output. That put every column name as a tag and the cell data within the tag.
However, now the criteria has changed on me. I need to create a tag with multiple sub tags in it.
Example: <Location Floor="10" Suite="512" DoorType="Metal">
But I'll still need other tags to be normal in the XML output such as
<Address>123 Fake St</Address>
<City>Springfield</City>
<Location Floor="10" Suite="512" DoorType="Metal">
Is there any way to get this XML mixed in the output like above?
Thank you for any help.Hi, you can FOR XML PATH for a finer degree of control over your XML. Use the @ symbol to create attributes. Here's a simple example:
DECLARE @t TABLE ( rowId INT IDENTITY PRIMARY KEY, [address] VARCHAR(50), city VARCHAR(30), floor INT, suite INT, doorType VARCHAR(20) )
INSERT INTO @t VALUES
( '123 Fake St', 'Springfield', 10, 512, 'Metal' )
SELECT
[address] AS "Address",
city AS City,
[floor] AS "Location/@Floor",
suite AS "Location/@Suite",
doorType AS "Location/@DoorType"
FROM @t
FOR XML PATH ('Company'), ROOT ('Companies'), ELEMENTS;
Maybe you are looking for
-
I am using an expense tracker and when I export the file for use it says it is in location /var/mobile/applications/666E-4BC6-8FF1-50CAD35FA541/documents/MyExpenses.csv where do I find this? Assistance greatly appreciated
-
You've Been Signed Out Error - Can't login to Desktop App
I cannot sign in to my CC desktop app, so I can't sink with typekit or update any of the applications. Every time I enter my credentials, I get a screen that says you've been signed out, see below. I attempted to delete the opm.db file, no change. I
-
Can I maually check for updates but prevent them from being automatically installed if it turns out one is available? Background: In options I have "check for updates, but let me choose whether to install them" ticked. This works fine, in that I peri
-
16:9 footage in a 4:3 sequence
i have some 16:9 footage that needs to go into a 4:3 sequence because all the other footage is shot 4:3. the only way i can see to have the 16:9 stuff looks like 4:3 is to bring it into the timeline then disort it -33% then enlarge to about 134%. is
-
BACKGROUND JOB WAS NOT SCHEDULED/LOG FILE NOT YET GENERATED
Hello, To generate the log report, /VIRSA/ZVFATBAK program is scheduled on hourly basis but some time report doesn't get generated and if we see the background job then it shows sucessfully finished. If we see the maually the log report for FFID then