XML ROWSET AND ROW...
hi,
declare
tab_domicilios col_domicilios; -- col_domicilios is a collection type
resul clob;
begin
-- select...
bulk collect into tab_domicilios
from...
SELECT SYS_XMLAGG (SYS_XMLGEN (VALUE (x))).getclobval() INTO resul
FROM TABLE (CAST (tab_domicilios AS col_domicilios)) x;
bdms_output.put_line(resul);
end;
the resul value is:
<?xml version="1.0"?>
<ROWSET>
<ROW>
<ID>394</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<IDTIPODOMICILIO>1</IDTIPODOMICILIO>
<NOMBRE>SAGUNTO</NOMBRE>
<NUMERO>174</NUMERO>
<RESTO>12 3</RESTO>
<IDPOBLACION>28856</IDPOBLACION>
<IDPERSONA>395</IDPERSONA>
<TIPODOMICILIO>
<ID>1</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<NOMBRE>Domicilio habitual</NOMBRE>
</TIPODOMICILIO>
<POBLACION>
<ID>28856</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<IDPROVINCIA>45</IDPROVINCIA>
<IDPAIS>1</IDPAIS>
<NOMBRE>VALENCIA</NOMBRE>
<COD_POSTAL>46009</COD_POSTAL>
</POBLACION>
<PAIS>
<ID>1</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<NOMBRE>ESPAÑA</NOMBRE>
<EUROPEO>S</EUROPEO>
<CODIGOHACIENDA>ES</CODIGOHACIENDA>
<PREFIJOTELEFONICO>34</PREFIJOTELEFONICO>
</PAIS>
<PROVINCIA>
<ID>45</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<IDAUTONOMIA>11</IDAUTONOMIA>
<NOMBRE>VALENCIA</NOMBRE>
</PROVINCIA>
</ROW>
<ROW>
<ID>559</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<IDTIPODOMICILIO>3</IDTIPODOMICILIO>
<NOMBRE>Balmes</NOMBRE>
<NUMERO>200</NUMERO>
<IDPOBLACION>531</IDPOBLACION>
<IDPERSONA>395</IDPERSONA>
<TIPODOMICILIO>
<ID>3</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<NOMBRE>Otras</NOMBRE>
</TIPODOMICILIO>
<POBLACION>
<ID>531</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<IDPROVINCIA>6</IDPROVINCIA>
<IDPAIS>1</IDPAIS>
<NOMBRE>BADALONA</NOMBRE>
<COD_POSTAL>08914</COD_POSTAL>
</POBLACION>
<PAIS>
<ID>1</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<NOMBRE>ESPAÑA</NOMBRE>
<EUROPEO>S</EUROPEO>
<CODIGOHACIENDA>ES</CODIGOHACIENDA>
<PREFIJOTELEFONICO>34</PREFIJOTELEFONICO>
</PAIS>
<PROVINCIA>
<ID>6</ID>
<ESTADOOBJETO>Original</ESTADOOBJETO>
<IDAUTONOMIA>7</IDAUTONOMIA>
<NOMBRE>BARCELONA</NOMBRE>
</PROVINCIA>
</ROW>
</ROWSET>
is possible change the name of ROW by FILA and ROWSET by GRAL
thank's in advance
SQL> SELECT SYS_XMLAGG (SYS_XMLGEN (VALUE (l),
SYS.xmlgenformattype.createformat ('MY_EMP')
SYS.xmlgenformattype.createformat ('MY_ROWSET')
) xml
FROM TABLE (CAST (MULTISET (SELECT *
FROM emp) AS emp_tab)) l
WHERE ROWNUM <= 5
XML
<?xml version="1.0"?>
<MY_ROWSET>
<MY_EMP>
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
<JOB>CLERK</JOB>
<MGR>7902</MGR>
<HIREDATE>17-DEC-80</HIREDATE>
<SAL>800</SAL>
<DEPTNO>20</DEPTNO>
</MY_EMP>
<MY_EMP>
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>20-FEB-81</HIREDATE>
<SAL>1600</SAL>
<COMM>300</COMM>
<DEPTNO>30</DEPTNO>
</MY_EMP>
<MY_EMP>
<EMPNO>7521</EMPNO>
<ENAME>WARD</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>22-FEB-81</HIREDATE>
<SAL>1250</SAL>
<COMM>500</COMM>
<DEPTNO>30</DEPTNO>
</MY_EMP>
<MY_EMP>
<EMPNO>7566</EMPNO>
<ENAME>JONES</ENAME>
<JOB>MANAGER</JOB>
<MGR>7839</MGR>
<HIREDATE>02-APR-81</HIREDATE>
<SAL>2975</SAL>
<DEPTNO>20</DEPTNO>
</MY_EMP>
<MY_EMP>
<EMPNO>7654</EMPNO>
<ENAME>MARTIN</ENAME>
<JOB>SALESMAN</JOB>
<MGR>7698</MGR>
<HIREDATE>28-SEP-81</HIREDATE>
<SAL>1250</SAL>
<COMM>1400</COMM>
<DEPTNO>30</DEPTNO>
</MY_EMP>
</MY_ROWSET>
Similar Messages
-
Regarding the rowset and row tags in the XML output
Hi,
We generated an XML file using dataset of type SQL query.The output is including additional tags
<ROWSET> and <ROW> tags.How to disable them from appearing in the XML output.Hi,
Iam not using the Datamodel of data template type.If we use the data template we can disable the rowtags by setting the property mentioned by you.But we get the data template name and the query name included in the output.My requirement is to disable the extratags.
Can u please provide inputs on how to disable the datatemplate name and the query name tags in the output when we use datatemplate.Thank you. -
Can't omit both the rowset and the row element?
consider the simple document below. Notice that row-element and
rowset-element are both empty, so neither type of element will
be generated. Also notice that the xsql:query tag is embedded in
other tags.
I get "oracle.xml.sql.OracleXMLSQLException: The row enclosing
tag or the row-set enclosing tag is ommitted; consequently to
get a well formed XML document, the result can only consist of a
single row with multiple columns or multiple rows with exactly
one column each." However, in reality the result will be a valid
XML document because I enclosed the query in a single top-level
<table> tag. So the error checking code in the XSQL servlet is
generating a generating a false positive (that is, seeing an
error that isn't there).
My question is, how can I work around this problem? I know I can
let the servlet generate a rowset element and use an XSLT
stylesheet to remove it but is there a another way?
Thanks,
Brian
By the way, the "numbers" table contains the numbers 1-1,000,000
and so it can be used to generate multiple copies of the output
of any query. In this example, I expect to get 55 <th> tags in
the output (yes, my HTML table is really that wide), all nested
in a single <tr> tag which is nested inside a single <table> tag.
<table connection="XXX"
xmlns:xsql="urn:oracle-xsql"
xmlns='http://www.w3.org/1999/xhtml'>
<tr><th rowspan='2'>ID</th>
<xsql:query rowset-element=''
row-element=''>
<![CDATA[
SELECT 'fvc' AS "th"
, 'fev1' AS "th"
, 'fef25_75' AS "th"
, 'fev1/fvc' AS "th"
, 'vc' AS "th"
, 'tlc' AS "th"
, 'rv' AS "th"
, 'frc_n2' AS "th"
, 'frc_pl' AS "th"
, 'erv' AS "th"
, 'dlco' AS "th"
FROM numbers
WHERE n < 5
]]>
</xsql:query>
</tr>
</table>In XML, single quotes are equivelent to double quotes. This
enables you to have attribute values like "That's Neat" and
'About 2" Long'.
The problem is that an xsql query can only return a tree as a
fragment (e.g. there must be one root element). I think this is
too restrictive. -
Dynamically creating XML using Sap-xMII Colum and Row Action Block
Hi,
I am trying to create a xMII-format XML using IlluminatorDocument Action Block.
My problem statement is during run time I am required to create columns on the fly.which I have done using xMII Colum Action block.but now I am required to assing values to these dynamically created columns.I have tried using Data Item and Row action block but am not sucessful in doing so.Can anyone help in creating this xml Dynamically.
The steps that I have followed is
defined
tagquery action block and defined tagquery
blank Illuminator Document Action block
put a repeater on result of tag query
set a counter
updated the counter
used column action block and mapped the column name i.e IlluminatorColumn_0.Name------"test"&Local.count
my column output looks like
Rowsets DateCreated="2007-03-27T12:59:39" EndDate="2007-03-27T11:42:40" StartDate="2007-03-27T11:42:40" Version="11.5.0">
<Rowset>
<Columns>
<Column Description="" MaxRange="100" MinRange="0" Name="test1" SQLDataType="1" SourceColumn="test1"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test2" SQLDataType="1" SourceColumn="test2"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test3" SQLDataType="1" SourceColumn="test3"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test4" SQLDataType="1" SourceColumn="test4"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test5" SQLDataType="1" SourceColumn="test5"/>
</Columns>
</Rowset>
</Rowsets>
after this action block i want to assign values to each column i.e
<Row/>
<Row/>
<Row/>
<Row/>
<Row/>
i.e erach row tags should be filled with columntag and value
but i am not able to achieve the same
Can anyone help me doing thisAfter adding IllumColum Action block I have created 5 columns dynamically
but now I am unable to add row.
currently for everycolumn created it is giving one row without any column node
the configurations that I have done in Data Item Action Block is
In My Link Editor
IlluminatorColumn_0.Name----
>IlluminatorDataItem_0.Name
hardcoded the value i.e 20----
>IlluminatorDataItem_0.Value
IlluminatorDocument_0.Output----
>IlluminatorDataItem_0.IlluminatorDocument
current resultset I am getting is
<?xml version="1.0" encoding="UTF-8"?>
<Rowsets DateCreated="2007-03-27T12:59:39" EndDate="2007-03-27T11:42:40" StartDate="2007-03-27T11:42:40" Version="11.5.0">
<Rowset>
<Columns>
<Column Description="" MaxRange="100" MinRange="0" Name="test1" SQLDataType="1" SourceColumn="test1"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test2" SQLDataType="1" SourceColumn="test2"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test3" SQLDataType="1" SourceColumn="test3"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test4" SQLDataType="1" SourceColumn="test4"/>
<Column Description="" MaxRange="100" MinRange="0" Name="test5" SQLDataType="1" SourceColumn="test5"/>
</Columns>
<Row/>
<Row/>
<Row/>
<Row/>
<Row/>
</Rowset>
</Rowsets> -
Xml validation and transformation in a row: Possible?
Hi.
I'm working on a small tool that uses javax.xml.validation and javax.xml.transform (JDK 6) to perform validation and transformation of xml files in a row.
The problem is, the namespaces and reference to the xml schema required by the validator somehow prevent the transformation from extracting data from the xml file.
Here's the header I use in the xml file:
<tagWhatever
xmlns="http://www.myPlace.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myPlace.com mySchema.xsd">To sum it up, with the namespace declaration within the xml I can validate but not transform, and without the declaration, I can transform but not validate.
Can anyone help me out witht this one?
Thanks
5thStringHi.
I'm working on a small tool that uses javax.xml.validation and javax.xml.transform (JDK 6) to perform validation and transformation of xml files in a row.
The problem is, the namespaces and reference to the xml schema required by the validator somehow prevent the transformation from extracting data from the xml file.
Here's the header I use in the xml file:
<tagWhatever
xmlns="http://www.myPlace.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.myPlace.com mySchema.xsd">To sum it up, with the namespace declaration within the xml I can validate but not transform, and without the declaration, I can transform but not validate.
Can anyone help me out witht this one?
Thanks
5thString -
How to fix skewed table columns and rows after re-import XML
My question is regarding XML Import in InDesign CS3.
I have a XML that has a table of 5 columns and 5 rows, when I import it into InDesign, the table shows up fine with 5 columns and 5 rows. However when I revise my table to have an additional column, and re-import the XML file, the table gets updated, but instead of with an additional column, it gets 'appended' with an additional row instead (InDesign seems to blindly replace each cell from left to right, top to bottom, and ends up with 6 rows instead). The XML file specifies the number of columns and rows (5 and 5 before, 5 and 6 after), why doesn't InDesign recognize it and automatically add a new column when I re-import the file? Is this problem fixed in CS5.5? Is there a script to fix this?
Here is an example of my old XML vs new XML:
Old:
<frame5>
<Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/" aid:table="table" aid:trows="5" aid:tcols="5">
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"></Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2006</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2005</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2004</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2003</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Stores at beginning of period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">846</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">805</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">753</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">678</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Stores opened during the period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">36</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">50</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">59</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">79</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Stores closed during the period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">13</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">9</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">7</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">4</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Total stores at end of period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">869</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">846</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">805</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">753</Cell>
</Table>
</frame5>
New:
<frame5>
<Table xmlns:aid="http://ns.adobe.com/AdobeInDesign/4.0/"
xmlns:aid5="http://ns.adobe.com/AdobeInDesign/5.0/" aid:table="table" aid:trows="5" aid:tcols="6">
<Cell aid:table="cell" aid:crows="1" aid:ccols="1"></Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2007</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2006</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2005</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2004</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">2003</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Stores at beginning of period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">123</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">846</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">805</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">753</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">678</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Stores opened during the period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">456</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">36</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">50</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">59</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">79</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Stores closed during the period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">789</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">13</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">9</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">7</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">4</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">Total stores at end of period</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">1368</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">869</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">846</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">805</Cell>
<Cell aid:table="cell" aid:crows="1" aid:ccols="1">753</Cell>
</Table>
</frame5>What I mean is, right now there is a "workaround" which requires a user to manually add an extra column before re-importing the XML (with an extra column), otherwise the results get skewed. If by providing a script we can simply ask the user to "run" it, it would be a more "acceptable" solution.
Right. So, one solution would be to use Convert Text to Tables. If you find that works for you, then you can script it.
That's why I asked you...
Of course if nothing is required from the user other than simply re-importing, then that would be the best solution.
Well, one could imagine a script that was attached to the re-import command, or to the link update notification, but probably the first step is to get something that works reasonably well without automating it completely. Especially because triggers to run scripts silently can introduce hard-to-debug problems.
Sure we can switch to use "CALS table and see if this works. The question is, why should we need to? In the 2nd XML there is clearly a different "aid:tcols" value, and yet InDesign seems to ignore it and assume the same # of columns? This sounds like an Indesign bug, can someone confirm? Is there any plans to fix this?
Not to be snarky, but do you want it to work or not? There are the tools you have and the tools you wish you had, and you can't really do much with the ones you wish you had. I'm kind of assuming you are looking for a solution today, not a solution in 2013.
Yes, I believe two of us have confirmed this appears to be a bug.
Plans to fix? Well, we can't really tell you. You could try asking Adobe, but that's not easy information to get out. But you can certainly open a support case at http://adobe.com/go/supportportal and ask. It's not like we have special information here...
But you're probably better off filing a bug first, in that same fashion.
But let's assume no one had filed the bug. CS6 is expected in the March/April 2012 timeframe. That means that they're probably just putting the finishing touches on it right now, and it's going to be very difficult to fix things in it now. So then the earliest you'd likely get it fixed in CS6.5/CS7/whatever which presumably comes out by 2Q2013, and that's assuming Adobe decides to fix it...
I also can't find much documentation on how to update my table to a "CALS table", any examples?
Try this thread:
Re: Importing a CALS table into InDesign CS3 -
XML, XSLT and Omniportlet
Hello, I hope I can find some help.
Using 10.1.14.
I'm importing an XML document. I don't know if it's in rowset/row format (don't know what that is).
I use XSL to transform it. When I click "test", I see pretty much what I want. A table tag, a td with a value, a td with another value, this repeats 4 times. This is the number of "item" elements I have. Great. Everything is set to default.
When I view my page, however, this is the response: Error fetching XML data. Or nothing, because I've tried many different configurations of XSL. When I view my page, it never works.
this is my xml:
<?xml version="1.0" encoding="UTF-8"?>
<record name="N/A" type="content">
<item name="Title"><value>Disclosure of Position Reclassifications</value></item>
<item name="Language"><value>eng</value></item>
<item name="Other Language File Name"><value>/sm/srh/prh/cngc/dsc/Reclass_f</value></item>
<item name="Content"><value>
& lt;table border="0" cellspacing="0" cellpadding="0" width="450"& gt;
& lt;tr& gt;
& lt;td colspan="3"& gt;& lt;h2& gt;Disclosure of Position Reclassifications& lt;/h2& gt;& lt;/td& gt;
& lt;/tr& gt;
& lt;/table& gt;
***LOTS OF HTML CLIPPED***
Act& lt;/u& gt;& lt;/i& gt;& lt;/a& gt; does not appear on this web site.& lt;/p& gt;
& lt;/td& gt;
& lt;/tr& gt;
& lt;/table& gt;
</value></item></record>
this is my xsl:
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="record">
<table>
<xsl:for-each select="item">
<tr>
<td><xsl:value-of select="@name"/></td>
<td><xsl:value-of select="value" disable-output-escaping="yes"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
</xsl:transform>Hi there,
I think missunderstand some basics.
to display XML documents, omniportlet takes in input onlu XML docs like this :
<rowset>
<row>my 1st line</row>
<row>my 2nd line</row>
<row> ... </row>
</rowset>
That means that the XML tags of your document MUST be ROWSET for the group and ROW for each element.
Omniportlet will render the previous XML fragment like this :
<table>
<tr>
<td>my 1st line</td>
<td>my 2ndline</td>
</tr>
<table>
So you got to write your XSL in order to transform your Initial XML in the rowset/row format. Omniportlet will take in charge of the HTML-table rendering.
Otherwise, your XML is not written in a good way. It should have been like this :
<?xml version="1.0" encoding="UTF-8"?>
<record name="N/A" type="content">
<Title>Disclosure of Position Reclassifications</Title>
<Language>eng</Language>
<OtherLanguageFileName>/sm/srh/prh/cngc/dsc/Reclass_f</OtherLanguageFileName>
<Content>
& lt;table border="0" cellspacing="0" cellpadding="0" width="450"& gt;
& lt;tr& gt;
& lt;td colspan="3"& gt;& lt;h2& gt;Disclosure of Position Reclassifications& lt;/h2& gt;& lt;/td& gt;
& lt;/tr& gt;
& lt;/table& gt;
***LOTS OF HTML CLIPPED***
Act& lt;/u& gt;& lt;/i& gt;& lt;/a& gt; does not appear on this web site.& lt;/p& gt;
& lt;/td& gt;
& lt;/tr& gt;
& lt;/table& gt;
</Content></record>I recommand you to have a look at XML tutorials : http://www.w3schools.com/xml/xml_elements.asp
XSL tutorials (if you need) : http://www.w3schools.com/xsl/
I hope this could help you. -
Compare 2 different xml versions and highlite the differences
Hi,
Currently we have xml and that is displayed on the web page using the css style sheets.
The xml we have remain the same most part but with small changes (say different version created after a week).
We want to be able to track the differences from the previous version and highlight them, the differences, when showing it in the web page.
Please advise if this can be done and how.
Thanks.try
SQL> set serveroutput on
SQL> set long 50000
SQL>
SQL> declare
2
3 --main
4 xml1 xmltype := xmltype('<ROWSET>
5 <ROW>
6 <EMPNO>7934</EMPNO>
7 <ENAME>MILLER</ENAME>
8 <JOB>CLERK</JOB>
9 <MGR>7782</MGR>
10 <HIREDATE>1982-01-23T00:00:00</HIREDATE>
11 <REMOVED>abc</REMOVED>
12 <SAL>1300</SAL>
13 <COMM/>
14 <DEPTNO>10</DEPTNO>
15 </ROW>
16 </ROWSET>');
17 --new
18 xml2 xmltype := xmltype('<ROWSET>
19 <ROW>
20 <EMPNO>7934</EMPNO>
21 <ENAME>MILLER</ENAME>
22 <JOB>CLERK</JOB>
23 <MGR>7782</MGR>
24 <ADDED>xyz</ADDED>
25 <HIREDATE>1982-01-23T00:00:00</HIREDATE>
26 <SAL>1300</SAL>
27 <COMM/>
28 <DEPTNO>10</DEPTNO>
29 </ROW>
30 </ROWSET>');
31 diff xmltype;
32
33 xtype varchar2(80);
34 xpath varchar2(80);
35 xpathChild varchar2(80);
36 xnodeChild varchar2(80);
37 new_value xmltype;
38
39 new_xml xmltype;
40
41
42 begin
43
44 -- get diff
45 select xmldiff(xml1, xml2) into diff from dual;
46 dbms_output.put_line(diff.getclobval());
47
48 -- that have
49 select x.xtype, x.xpath, x.new_value
50 into xtype, xpath, new_value
51 from xmltable(
52 xmlnamespaces('http://xmlns.oracle.com/xdb/xdiff.xsd' as "xd"
53 ,'http://www.w3.org/2001/XMLSchema-instance' as "xsi"
54 )
55 , '/xd:xdiff'
56 passing diff
57 columns xtype varchar2(80) path 'local-name(xd:insert-node-before)'
58 , xpath varchar2(80) path'xd:insert-node-before/@xd:xpath'
59 , new_value xmltype path 'xd:insert-node-before/xd:content/*'
60 ) x;
61
62 dbms_output.put_line('type of doing: ' || xtype);
63 dbms_output.put_line('path for doing: ' || xpath);
64 dbms_output.put_line('value for doing: ' || new_value.getclobval());
65
66 if (xtype = 'insert-node-before') then
67 xpathChild := substr(xpath, 1, instr(xpath, '/',-1)-1);
68 xnodeChild := substr(xpath, instr(xpath, '/',-1)+1);
69
70 select insertChildXMLbefore (xml1,
71 xpathChild,
72 xnodeChild,
73 XMLType('<HIGHLIGHT>' || new_value || '</HIGHLIGHT>'))
74 into new_xml
75 from dual;
76 end if;
77
78
79 dbms_output.put_line(new_xml.getclobval());
80
81 end;
82 /
<xd:xdiff xsi:schemaLocation="http://xmlns.oracle.com/xdb/xdiff.xsd http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xd="http://xmlns.oracle.com/xdb/xdiff.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><?oracle-xmldiff operations-in-docorder="true" output-model="snapshot" diff-algorithm="global"?><xd:insert-node-before xd:node-type="element" xd:xpath="/ROWSET[1]/ROW[1]/HIREDATE[1]"><xd:content><ADDED>xyz</ADDED></xd:content></xd:insert-node-before><xd:delete-node xd:node-type="element" xd:xpath="/ROWSET[1]/ROW[1]/REMOVED[1]"/></xd:xdiff>
type of doing: insert-node-before
path for doing: /ROWSET[1]/ROW[1]/HIREDATE[1]
value for doing: <ADDED>xyz</ADDED>
<ROWSET><ROW><EMPNO>7934</EMPNO><ENAME>MILLER</ENAME><JOB>CLERK</JOB><MGR>7782</MGR><HIGHLIGHT><ADDED>xyz</ADDED></HIGHLIGHT><HIREDATE>1982-01-23T00:00:00</HIREDATE><REMOVED>abc</REMOVED><SAL>1300</SAL><COMM/><DEPTNO>10</DEPTNO></ROW></ROWSET>
PL/SQL procedure successfully completed
SQL>
SQL> select * from v$version where rownum=1;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
SQL> -
How to convert a data set into a xml data and vice versa
i am new to oracle with xml..
my aim is to convert a data set into a xml data and vice versa..
my work is as follows...
my query:
select rggpk,rggcode,rggname from ms_regiongeo
to convert a data set into a xml*
select XMLType(trim(replace(dbms_xmlgen.getXML('select rggpk,rggcode, rggname from ms_regiongeo'),'<?xml version="1.0"?>',''))) XML_DATA from dual;
(this works fine and output of this query is as follows..)
<ROWSET>
<ROW>
<RGGPK>201</RGGPK>
<RGGCODE>Asia</RGGCODE>
<RGGNAME>Asia</RGGNAME>
</ROW>
<ROW>
<RGGPK>1</RGGPK>
<RGGCODE>OTH</RGGCODE>
<RGGNAME>Others</RGGNAME>
</ROW>
<ROW>
<RGGPK>21</RGGPK>
<RGGCODE>COB</RGGCODE>
<RGGNAME>Africa and Yemen</RGGNAME>
</ROW>
<ROW>
<RGGPK>2</RGGPK>
<RGGCODE>AUS</RGGCODE>
<RGGNAME>Australia</RGGNAME>
</ROW>
<ROW>
<RGGPK>23</RGGPK>
<RGGCODE>IND</RGGCODE>
<RGGNAME>Indian Sub Continent</RGGNAME>
</ROW>
<ROW>
<RGGPK>24</RGGPK>
<RGGCODE>TVM</RGGCODE>
<RGGNAME>North America</RGGNAME>
</ROW>
</ROWSET>
and to reverse this process, I tried a query like this..*
select EXTRACTVALUE (XML_DATA,'ROWSET/ROW/RGGPK') as EMP_ID
from(
select XMLType(trim(replace(dbms_xmlgen.getXML('select rggpk,rggcode, rggname from ms_regiongeo'),'<?xml version="1.0"?>',''))) XML_DATA from dual
)tab1but failed.. and raised with an eror: ORA-19025
help me..
regards,
johnHi-
my aim is to convert a data set into a xml data You can refer to the below posts
Adding namespace to XML output
Re: how to convert table data in xml format based on the xsd. -
Hi,
I have a question about the XML SQL Utility.
Must I have the <ROOTDOC> and <ROW> TAG's in my XML-Document to insert the Document with the Utility in my Database, or can I use a random defined TAG as start TAG, e.g. the <BOOK_ID>.
XML-Document:
Book.xml
<?xml version="1.0" encoding="UTF-16"?>
<!DOCTYPE ANWENDUNGEN SYSTEM "file:/E:/book.dtd">
<!-- ?xml-stylesheet href="book.xsl" type="text/xsl"? -->
<ROOTDOC>
<ROW>
<BOOK_ID>55-66</BOOK_ID>
<BOOK_NAME>JavaScript</BOOK_NAME>
<REF_TO_PRICE>2-AA</REF_TO_PRICE>
<PRICE_ID>2-AA</PRICE_ID>
<PRICE_DM>55.50DM</PPRICE_DM>
</ROW>
</ROOTDOC>
Can anyone help me, please ?
Thanks
nullYou can use a "random" tag at the "ROW" tag, using the -rowTag XXXX command line option.
The utility will attempt to insert the CHILDREN elements of the rowset as if they were the columns of each ROW in the table whose name you provide. -
Populate Local XML File, and Loop through it
I created a local property of type XML. I want to populate this variable with the results of a SQL query, and store it in local memory. Then later, I will loop through this file and perform actions. Basically I am going to have to loop through this resultset many times, and if I can store it in memory, I won't have to re-qurey the DB>
#1 Is this possible?
Right now, I use a repeater on the SQL, and assign the rowset/rowset/row to the local XML Variable.(Assign XML). SHould I use Assign XML, or APpend XML for the Link Type
THen later I am trying a repeater to loop through the flle, and I have no idea where to point the xpath expression to.
Thanks for the help in advance,
JEffFrom what I understand you are trying to do - Rather than repeating on the SQL query you can link the "Result" of the SQL Query action to the local property (type xml) [and yes you just say Assign XML instead of Append or anything else].
What this would do is assign the local variable the results of the SQL Query in an xMII XML format and then you can further work on this XML.
But rather than using the local variable you can repeat on the SQL Query Action (the way you are doing currently) and manipulate what ever you want to. There is no question of requerying the DB as ur DB would be queried only one time (the SQL Query Action Block will ensure this) and then the repeater would be repeating only on the resulset rendered by the SQL Query action.
Did this make it clearer or have I not understood your problem? -
Extracting XML tags and its values using ORACLE PL/SQL
I need help to create a procedure that receive a XML string and insert it into the table after parsing it.
If the XML has 10 tags then it should insert into the table 10 rows. Table will be having tag name and value. This will be plain XML tags without attributes in tags.Hi,
I am able to retreive the values of the tags using extract function (example: lv_xml.EXTRACT ('/ROWSET/EMPLOYEE/EMPNO/text()').getstringval() ). But could you help me to find some way to extract the tags also since we have no idea what the tags are and how many tags are there, in advance.
Anybody's help will be a releif!
Thanks in advance,
Leslie
Message was edited by:
user544830 -
Problem with XML loading and xmlns
I'm having a problem with loading an XML file that was created by Filemaker. Filemaker will output an XML file using one of two different grammars. One outputs in a mostly standard form that I can use with one glitch. Flash CS4 AS3 seems to have a problem with the xmlns in one of the nodes.
Specifically:
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
If I remove the xmlns="http://www.filemaker.com/fmpdsoresult" the file loads properly and I can access the various fields with no problem. However, when I leave the xmlns=... in, it will trace out the XML properly but I can't access the fields using the code listed below. This is driving me crazy!
With the xmlns part in the XML file I get the following error when it tries to load the thumbnail files:
TypeError: Error #1010: A term is undefined and has no properties.
I need to have it so that the user can enter/edit data and simply output the XML file from Filemaker and then Flash will load up the unaltered XML file and show the info requested by the user. That is to say I could have the user open the XML file in a word processing application and have them delete the xmlns..., but that is rather cumbersome and not very user friendly.
I've tried every xml.ignore function I could find but it doesn't help. Hopefully someone out there can help
Thanks,
-Mark-
Partial XML:
XML From Filemaker Export:
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This grammar has been deprecated - use FMPXMLRESULT instead -->
<FMPDSORESULT xmlns="http://www.filemaker.com/fmpdsoresult">
<ERRORCODE>0</ERRORCODE>
<DATABASE>Sport.fp7</DATABASE>
<LAYOUT></LAYOUT>
<ROW MODID="1" RECORDID="1">
<FirstName>Mark</FirstName>
<LastName>Fowle</LastName>
<Sport>Sailing</Sport>
<Medal>None</Medal>
<CourseOfStudy>Design</CourseOfStudy>
<Year>1976-1978</Year>
<HomeState>California</HomeState>
<ImageName>93</ImageName>
</ROW>
</FMPDSORESULT>
AS3 Code:
import fl.containers.UILoader;
var aPhoto:Array=new Array(ldPhoto_0,ldPhoto_1,ldPhoto_2,ldPhoto_3,ldPhoto_4,ldPhoto_5);
var toSet:int=10;//time out set time
var toTime:int=toSet;
var photoPerPage:int=6;
var fromPos:int=photoPerPage;
var imgNum:Number;
//var subjectURL:URLRequest=new URLRequest("testData_FM8.xml");
var subjectURL:URLRequest=new URLRequest("Sports.xml");
var xmlLoader:URLLoader=new URLLoader(subjectURL);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
var subjectXML:XML = new XML();
subjectXML.ignoreWhitespace=true;
subjectXML.ignoreComments=true;
subjectXML.ignoreProcessingInstructions=true;
function xmlLoaded(evt:Event):void {
subjectXML=XML(xmlLoader.data);
if (root.loaderInfo.bytesTotal==root.loaderInfo.bytesLoaded) {
removeEventListener(Event.ENTER_FRAME, xmlLoaded);
trace("XML Data File Loaded");
trace(subjectXML);
} else {
trace("File not Found");
imgNum=2;//subjectXML.ROW.length;
trace(subjectXML);
loadThumb(0);
function loadThumb(startPos:int):void {
var count:Number=aPhoto.length;
trace(subjectXML.DATABASE);
for (var i=0; i<count; i++) {
try{
aPhoto[i].source="images/"+subjectXML.ROW[startPos+i].ImageName+"_main.jpg";
}catch (e:Error){
trace(e);
aPhoto[i].mouseChildren=false;
aPhoto[i].addEventListener(MouseEvent.MOUSE_DOWN, onThumbClick);
trace("Current mem: " + System.totalMemory);
ldAttract.visible=false;
function unloadThumb():void {
var count:Number=aPhoto.length;
for (var i=0; i<count; i++) {
aPhoto[i].unload();
aPhoto[i].removeEventListener(MouseEvent.MOUSE_DOWN, onThumbClick);
trace("Current mem: " + System.totalMemory);
function onThumbClick(evt:MouseEvent) {
var i:Number;
//trace("Thumbnail Clicked " + evt.target.name);
i=findPos(evt.target.name);
ldLrgPhoto.source="images/"+subjectXML.ROW[i+fromPos].LOCAL_OBJECT_ID+"_main.jpg";
ldLrgPhoto.visible=true;
btnPrev.visible=false;
btnNext.visible=false;
gotoAndStop("showPhoto");
function findPos(thumb:String):Number {
var pos:Number;
var count:Number=aPhoto.length;
for (var i:Number=0; i<count; i++) {
if (thumb==aPhoto[i].name) {
pos=i;
return pos;Hi,
I was trying to use xml namespaces, so in my application I receive an XML file from the server. The file has a namespace, so when I parse the file I need to specify the namespace:
I got the following piece of xml:
<ls:exchange xmlns:ls=".../tsw" xmlns:tm="http://kxa">
<ls:projects>
<tm:annotation id="" date="" action="getprojects" status="responseok"/>
<ls:project id="" name="proj" description="..." owner="asss" release="2" />
<ls:projectV id="" version="" creationdate="" modificationdate=""/ >
</ls:project>
</ls:projects>
</ls:exchange>
and the following code
<mx:VBox label="WELCOME" verticalScrollPolicy="off" horizontalScrollPolicy="off">
<mx:Tree id="tree" dataProvider="{srv.lastResult.project}" labelField="@name" width="300" height="100%" itemOpen="itemOpenEvt(event);" />
</mx:VBox>
So i want to display the content of the xml (project nodes”) in a tree view, but i don’t know how to includes the namespace"ls:" in the data provider “srv.lastResult.project”. can u help me it’s urgent.
sincerly
Celine -
XML,CLOB AND MEMORY : CONSUMED BUT NOT RELEASED !!!
Hi,
I'm working with XMLGEN Package and XSLT Processor to produce XML Document on Oracle 8.1.7.3 server, I use 9i XML and Java packages.
I'm facing the following BIG MEMORY problem :
Environment : I must generate an XML parsed with an XSL document of 80Mo (nearly 22 000 rows),
as XMLGEN is on DOM parsing method, I extract my XML by 500 Rows and I loop until 22 000 rows. I use DBMS_JOB with jobs who read and execute export each minute.
The algorithme is :
keeprow=22000
while keeprow>0
Create 3 clob (DBMS_LOB Package) : one for XSL Sheet, one for XML and one for result
GetXML (XMLGEN Package)
Transform in XSL (XSL Processor)
Write to disk (UTL_FILE Package)
Free the 3 Clob ((DBMS_LOB Package))
keeprow =keeprow-500
loop
The problem : The process start at 250Mo ot total memory and END at 1000 Mo of used memory and NEVER RELEASE 1 ko of memory.
So often I get a JavaOutOfMemoryError (I've allocated 1Go Ram to my JAVA process).
Any help will be very very appreciated !
My derived problem is 22 000 rows is not enough I've some export of 200 000 rows to do (And I cannot allocate 10 Go of RAM !!!)
Following My PL/SQL Code.
Regards
Fred
PROCEDURE DO_EXPORT_XML(
P_JOB_ID JOB_PARAMETRE.JOB_ID%TYPE,
P_JOB_ID_ORDRE JOB_PARAMETRE.JOB_ID_ORDRE%TYPE,
P_CLE_UP UPLOADREQ_TEMP.ID%TYPE,
P_LOAD_OR_DELOAD VARCHAR2)
IS
L_FILE_NAME JOB_PARAMETRE.JOB_FILE_NAME_DEST%TYPE;
L_REP_NAME JOB_PARAMETRE.JOB_REP_NAME_DEST%TYPE;
L_FILE_STYLESHEET JOB_PARAMETRE.JOB_STYLESHEET%TYPE;
L_VERSION_PDM JOB_PARAMETRE.JOB_VPDM%TYPE;
P_SELECT varchar2(4000):='';
P_CURSOR varchar2(4000):='';
l_filehandler_out UTL_FILE.FILE_TYPE;
--Variable pour le traitement par lot de 500
L_NBROW_TODO_ATONCE number := 500;
L_NBROW_MIN number := 1;
L_NBROW_MAX number := -1;
L_NBROWKEEPTODO number := -1;
xslString CLOB := null;
res number default -1;
xmlString CLOB := null;
li_ret number := 0;
li_faitle number := 0;
amount integer:= 255;
li_loop integer := 0;
charString varchar2(255);
ls_deload varchar2(255) default '';
ls_SQL varchar2(4000) default '';
ls_temp_file varchar2(255) default '';
text_file_dir varchar2(32) := 'e:\temporarydir';
l_par xmlparser.parser;
l_xml xmldom.domdocument;
l_pro xslprocessor.processor;
l_xsl xslprocessor.stylesheet;
docfragnode xmldom.DOMNode;
docfrag xmldom.DOMDocumentFragment;
l_parsedclob clob := null;
l_amount binary_integer := 32767;
l_ligne varchar2(32767);
l_offset number default 1;
l_pos number default null;
l_pos2 number default null;
l_lobsize number default null;
l_memsize number default 1073741824; --1024 Mo
l_mempipo number default 0;
type rc is ref cursor;
l_cursor rc;
cursor TEMPLATE is select UNSPSC,1 as NB from UPLOADREQ_TEMP where 1=2;
c1rec TEMPLATE%rowtype;
BEGIN
l_mempipo:=setmaxmemorysize(l_memsize);
dbms_lob.createtemporary(l_parsedclob, true, dbms_lob.session);
dbms_lob.createtemporary(xmlstring, true, dbms_lob.session);
--return the good select
GET_SELECT_TO_EXPORT_XML(P_JOB_ID , P_JOB_ID_ORDRE , P_CLE_UP , P_SELECT,P_CURSOR, P_LOAD_OR_DELOAD);
SELECT JOB_FILE_NAME_DEST,JOB_REP_NAME_DEST,JOB_STYLESHEET
INTO L_FILE_NAME,L_REP_NAME,L_FILE_STYLESHEET
FROM JOB_PARAMETRE
WHERE JOB_ID =P_JOB_ID AND JOB_ID_ORDRE=P_JOB_ID_ORDRE;
l_filehandler_out := UTL_FILE.FOPEN(text_file_dir, L_FILE_NAME, 'w',l_amount);
--Return XSL Sheet in a clob : cause of memory consumed but not released
xslString := METACAT.load_a_file( 1,L_FILE_STYLESHEET);
open l_cursor for P_CURSOR;
LOOP
fetch l_cursor into c1rec;
exit when l_cursor%notfound;
L_NBROW_MIN := 1;
L_NBROW_MAX := 0;
L_NBROWKEEPTODO:=c1rec.NB;
LOOP
begin
if(L_NBROWKEEPTODO > L_NBROW_TODO_ATONCE) THEN
begin
L_NBROW_MAX:= L_NBROW_TODO_ATONCE + L_NBROW_MAX;
L_NBROWKEEPTODO:= L_NBROWKEEPTODO - L_NBROW_TODO_ATONCE;
end;
else
begin
L_NBROW_MAX:= L_NBROW_MAX + L_NBROWKEEPTODO;
L_NBROWKEEPTODO:=0;
end;
end if;
--on ouvre le fichier de risultats
ls_SQL:= P_SELECT || ' AND ( ROWNUM BETWEEN ' || L_NBROW_MIN || ' AND ' || L_NBROW_MAX || ' ) and UNSPSC=''' || c1rec.UNSPSC || '''';
ls_temp_file := c1rec.UNSPSC || '_' || L_FILE_NAME;
L_NBROW_MIN:=L_NBROW_TODO_ATONCE + L_NBROW_MIN;
--CAT_AUTOLOAD.JOB_ADD_TRACE (P_JOB_ID,'UPLOAD REQUISITE : Export donnies REQUETE ' || to_char(li_loop), ls_SQL,'',0,0);
xmlgen.resetOptions;
xmlgen.setErrorTag('ERROR_RESULT');
xmlgen.setRowIdAttrName('NAH');
xmlgen.setRowIdColumn('NAH');
xmlgen.setEncodingTag('ISO-8859-1');
xmlgen.useNullAttributeIndicator(false);
if(xmlString is not null) then
dbms_lob.open(xmlString,dbms_lob.lob_readwrite);
l_lobsize:= dbms_lob.Getlength(xmlString);
if(l_lobsize>0) then
dbms_lob.erase(xmlString,l_lobsize,1);
end if;
dbms_lob.close(xmlString);
dbms_lob.freetemporary(xmlString);
dbms_lob.createtemporary(xmlstring, true, dbms_lob.session);
end if;
--Return XML in a clob : cause of memory consumed but not released
xmlString := xmlgen.getXML(ls_SQL,0);
l_par := xmlparser.newparser;
xmlparser.parseclob(l_par, xslString);
l_xsl := xslprocessor.newstylesheet(xmlparser.getdocument(l_par),null);
xmlparser.parseclob(l_par, xmlString);
l_xml := xmlparser.getdocument(l_par);
l_pro := xslprocessor.newprocessor;
xslprocessor.showWarnings(l_pro, true);
xslprocessor.setErrorLog(l_pro, text_file_dir || substr(ls_temp_file,0,length(ls_temp_file)-4) || '_logerreur.XML');
if(l_parsedclob is not null) then
dbms_lob.open(l_parsedclob,dbms_lob.lob_readwrite);
l_lobsize:= dbms_lob.Getlength(l_parsedclob);
if(l_lobsize>0) then
dbms_lob.erase(l_parsedclob,l_lobsize,1);
end if;
dbms_lob.close(l_parsedclob);
dbms_lob.freetemporary(l_parsedclob);
dbms_lob.createtemporary(l_parsedclob, true, dbms_lob.session);
end if;
--Return XML Processed with XSL in a clob : cause of memory consumed but not released
xslprocessor.processxsl(l_pro,l_xsl,l_xml,l_parsedclob);
--release NOTHING
xmlparser.freeparser(l_par);
xslprocessor.freeprocessor(l_pro);
l_ligne:='';
l_offset :=1;
l_pos := null;
l_pos2 := null;
if(li_loop=0) then
begin
--on ouvre le fichier et on sauve l'entete + les donnies dedans.
l_pos:=dbms_lob.instr(l_parsedclob,'</DATA>');
if ( nvl(l_pos,0) > 0 ) then
loop
if(l_pos-1>l_amount + l_offset ) then
l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_amount,l_offset);
UTL_FILE.PUT(l_filehandler_out,l_ligne);
UTL_FILE.fflush(l_filehandler_out);
l_offset:=l_offset+l_amount;
else
l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_pos-1 -l_offset ,l_offset);
UTL_FILE.PUT(l_filehandler_out,l_ligne);
UTL_FILE.fflush(l_filehandler_out);
exit;
end if;
end loop;
else
EXIT;
end if;
end;
else
--on met les donnies donc on ne repete pas le debut
begin
l_pos:=dbms_lob.instr(l_parsedclob,'<ITEM');
if ( nvl(l_pos,0) > 0 ) then
l_pos2:=dbms_lob.instr(l_parsedclob,'</DATA>');
if ( nvl(l_pos2,0) > 0 ) then
loop
if(l_pos + l_amount <= l_pos2 -1 ) then
l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_amount,l_pos);
UTL_FILE.PUT(l_filehandler_out,l_ligne);
UTL_FILE.fflush(l_filehandler_out);
l_pos:=l_pos +l_amount;
else
l_ligne:=dbms_lob.SUBSTR(l_parsedclob,l_pos2 -1 -l_pos,l_pos);
UTL_FILE.PUT(l_filehandler_out,l_ligne);
UTL_FILE.fflush(l_filehandler_out);
exit;
end if;
end loop;
else
exit;
end if;
end if;
end;
end if;
li_loop:=li_loop + 1 ;
--UTL_FILE.FCLOSE(l_filehandler_in);
JAVA_GC();
EXIT WHEN L_NBROWKEEPTODO=0;
Exception
when others then
begin
-- IF(utl_file.is_open(l_filehandler_in)) THEN
-- utl_file.fclose( l_filehandler_in);
-- END IF;
IF(utl_file.is_open(l_filehandler_out)) THEN
utl_file.fclose( l_filehandler_out);
END IF;
RAISE_APPLICATION_ERROR(-20001,'File with errors');
end;
END;
END LOOP;
END LOOP;
CLOSE l_cursor;
if ( xmlString is not null ) then
dbms_lob.open(xmlString,dbms_lob.lob_readwrite);
l_lobsize:= dbms_lob.Getlength(xmlString);
if(l_lobsize>0) then
dbms_lob.erase(xmlString,l_lobsize,1);
end if;
dbms_lob.close(xmlString);
dbms_lob.freeTemporary( xmlString);
end if;
if(l_parsedclob is not null) then
dbms_lob.open(l_parsedclob,dbms_lob.lob_readwrite);
l_lobsize:= dbms_lob.Getlength(l_parsedclob);
if(l_lobsize>0) then
dbms_lob.erase(l_parsedclob,l_lobsize,1);
end if;
dbms_lob.close(l_parsedclob);
dbms_lob.freetemporary(l_parsedclob);
end if;
UTL_FILE.NEW_LINE(l_filehandler_out);
l_ligne:='</DATA></CATALOG>';
UTL_FILE.PUT(l_filehandler_out,l_ligne);
UTL_FILE.FCLOSE(l_filehandler_out);
EXCEPTION
when others then
begin
IF(utl_file.is_open(l_filehandler_out)) THEN
utl_file.fclose( l_filehandler_out);
END IF;
end;
END;
******************************Thank you for the info - I had no idea I was puing myself in danger by cutting it so close. Since your post I have moved my iphoto library to an external drive and now have 165 GB of space on my HD. Following this I have 2 questions.
1. Since my available HD space was reduced by the size of the photo download it seems logical that the download is somewhere on my HD still. Is there a place where these photos might be hiding on my HD even though they are not available on the iphoto library?
2. I was able to recover the .jpg files which are fine. I also recovered the .mov files but they have been compromised. I am hoping I can find the originals still on the HD somewhere. If not, do you have any suggestions for recovery methods or programs? I have not used the SD card since the incident so I should be able to attempt another recovery to salvage the .mov files if there is an alternative method/program available.
Thanks again! -
How to parse XML Column and insert values into a table
Hello,
I am working on a simple project to demonstrate how to load and extract XML using SQL, I have already made a table that contains a column of XMLTYPE and loaded an XML file into it (code below)
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
I now however need to get the XML data back out of that and loaded into a new table. Troubleshooting guides I have read online seem to only be dealing with parsing an external XML document and loading it into a table, and not what I need to do which is parse a column of XML data and load that into a table. The project trivial with simple tables containing only 3 columns.
The table that needs to be loaded is as follows:
create table InventoryOut(PartNumber Number(10), QTY Number(10), WhLocation varchar2(500));
The XML document is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thank you for any help you can offer.First of all, thank you for your help!! Still stunned that you actually took the time to write out an eample using my tables/names/etc. Thank you!!
Attached is the code, there seems to be an issue with referencing the other table, Inventory.Inv, I checked and that table and the Inv column are showing up in the database so I am not sure why it is having issues locating them, take a look at the code I wrote as well as the output (*I included the real version number for you this time :)
EDIT: In your code right here:
select xt.*
3 from Inventory inve,
4 XMLTable('/dataroot/Inventory'
5 PASSING inve.Inv
I think is where I am messing it up, perhaps not understanding fully what is going on, as you write "Inventory inve" and "inve.Inv" ---- Is inve a keyword that I am just not familiar with? I think this is where the issues lies in my code.
END EDIT
EDIT2: Well that looks like it was it, changed that to how you have it and it now works!!! Could you please explain what that few lines is doing, and what the xt.* and inve are doing? Thanks again!!!
END EDIT2
drop table InventoryOut;
create table InventoryOut (PartNumber number(10), QTY number(10), WhLocation varchar2(500));
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt;
select * from InventoryOut;
select * from v$version;
table INVENTORYOUT dropped.
table INVENTORYOUT created.
Error starting at line 4 in command:
insert into InventoryOut (PartNumber, QTY, WhLocation)
select xt.*
from Inventory Inv,
XMLTable('/dataroot/Inventory'
PASSING Inventory.Inv COLUMNS
PartNumber number path 'PartNumber',
QTY number path 'QTY',
WhLocation path 'WhLocation')xt
Error at Command Line:8 Column:12
Error report:
SQL Error: ORA-00904: "INVENTORY"."INV": invalid identifier
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action:
PARTNUMBER QTY WHLOCATION
BANNER
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
If this helps here is the code and output for the creation of the Inventory table itself:
create or replace directory XMLSRC as 'C:\XMLSRC';
drop table Inventory;
create table Inventory(Inv XMLTYPE);
INSERT INTO Inventory VALUES (XMLTYPE(bfilename('XMLSRC', 'Inventory.xml'),nls_charset_id('AL32UTF')));
select * from Inventory;
directory XMLSRC created.
table INVENTORY dropped.
table INVENTORY created.
1 rows inserted.
INV
<?xml version="1.0" encoding="WINDOWS-1252"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2012-04-09T17:36:30">
<Inventory>
<PartNumber>101</PartNumber>
<QTY>12</QTY>
<WhLocation>WA</WhLocation>
</Inventory>
</dataroot>
Thanks again for your help so far! Hope we can get this working :)
Edited by: 926502 on Apr 11, 2012 2:47 PM
Edited by: 926502 on Apr 11, 2012 2:49 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Edited by: 926502 on Apr 11, 2012 2:54 PM
Updated issue to solved - Edited by: 926502 on Apr 11, 2012 2:55 PM
Maybe you are looking for
-
Can not create a sdn userid, going to same page again and again
Hi, I got my S000 ID from certification, by using which I have logged in to sdn. When I try to shop/buy some thing it is saying I need to use some public id. I created a new userid one but when I try to logon, it is not letting me to to goto any
-
Bad performance on Factory.parse method
Hi all, I have some classes created from an XML Schema. I'm using them to load an XML from disk instead of using SAX or DOM. The problem is that I have monitorized the performance with OptimizeIt and every time I call the XXXXType.Factory.Parse(Input
-
Extension Manager 6.0.4
Hi all, update to extension manager 6.0.4 aborts with code U44M1P7. Whats happen? Thanks all Olaf
-
Links break on complex imported AI documents in new AI document
I'm creating a series of mapsheets for various projects in Illustrator. Rather than recreating a base map for each mapsheet, I've created tiles with various features such as shoreline, rivers, lakes, contours and even hillshade rendering that can be
-
How do I add either a line Feed or Carriage Return to a column?
I am using "Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production" "PL/SQL Release 11.2.0.1.0 - Production" "CORE 11.2.0.1.0 Production" "TNS for Linux: Version 11.2.0.1.0 - Production" "NLSRTL Version 11.2.0.1.0 - Production"