DBMS_XSLPROCESSOR
I have the following XML which I want to extract each value for the following:
*<TN>VALUE1</TN>*
*<TN2>VALUE2</TN2>*
*<TN>ANOTHER VALUE 1</TN>*
*<TN2>SECOND VALUE 2</TN2>*
and the following values:
*<DetailLine1>Detail line 1 value</DetailLine1>*
*<DetailLine2>detail line 2 value</DetailLine2>*
*<DetailLine1>Another value for detail line 1</DetailLine1>*
*<DetailLine2>second value for detail line 2 </DetailLine2>*
The XML I get is the following and I am using the code below but I get nothing as result - lenght is zero as result of DBMS_XMLDOM.GETLENGTH(v_nl));
Would you please help me, I am new in this and I have spent a lot in research and this has not worked.
p_xmltext varchar2(4000);
v_parser DBMS_XMLPARSER.Parser;
v_xmldoc DBMS_XMLDOM.DOMDocument;
v_nl DBMS_XMLDOM.DOMNodeList;
v_n DBMS_XMLDOM.DOMNode;
begin
p_xmltext:= '
<?xml version="1.0" encoding="utf-8" ?>
- <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <soap:Body>
- <SDResp xmlns="http://www.Aplace.com/processserver">
- <SDResult>
- <IDT>
<string>111</string>
<string>222</string>
</IDT>
- <ORD>
<ONumber>3105</ONumber>
<ACC>ABC</ACC>
- <Items>
- <Items>
<TN>VALUE1</TN>
<TN2>VALUE2</TN2>
- <DETAIL>
<DetailLine1>Detail line 1 value</DetailLine1>
<DetailLine2>detail line 2 value</DetailLine2>
</DETAIL>
</Items>
- <Items>
<TN>ANOTHER VALUE 1</TN>
<TN2>SECOND VALUE 2</TN2>
- <DETAIL>
<DetailLine1>Another value for detail line 1</DetailLine1>
<DetailLine2>second value for detail line 2 </DetailLine2>
</DETAIL>
</Items>
</Items>
</ORD>
</SDResult>
</SDResp>
</soap:Body>
</soap:Envelope>';
v_parser := DBMS_XMLPARSER.newParser;
DBMS_XMLPARSER.parseBuffer(v_parser, p_XMLText);
v_xmldoc := DBMS_XMLPARSER.getDocument(v_parser);
-- Free resources associated with the Parser now it is no longer needed.
DBMS_XMLPARSER.freeParser(v_parser);
v_nl := DBMS_XSLPROCESSOR.selectNodes(DBMS_XMLDOM.makeNode(v_xmldoc),'//Items);
dbms_output.put_line('Number of records is '||DBMS_XMLDOM.GETLENGTH(v_nl));
Edited by: user3564713 on Apr 20, 2010 10:19 PM
Edited by: user3564713 on Apr 20, 2010 10:19 PM
The sample XML you provided in your first post does not have any nodes with the names in the XPaths you listed so I'm not surprised it didn't work.
Here is a starter version that works for you based off your first post. I got rid of using // because that is a slight performance hit and I try to avoid it when possible.
declare
indoc VARCHAR2(2000);
indomdoc dbms_xmldom.domdocument;
l_nl dbms_xmldom.DOMNodeList;
lv_value VARCHAR2(30);
l_n dbms_xmldom.DOMNode;
l_xmltype XMLTYPE;
l_body XMLTYPE;
l_index PLS_INTEGER;
begin
-- Test statements here
l_xmltype := XMLTYPE('<?xml version="1.0" encoding="utf-8" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<SDResp xmlns="http://www.Aplace.com/processserver">
<SDResult>
<IDT>
<string>111</string>
<string>222</string>
</IDT>
<ORD>
<ONumber>3105</ONumber>
<ACC>ABC</ACC>
<Items>
<Items>
<TN>VALUE1</TN>
<TN2>VALUE2</TN2>
<DETAIL>
<DetailLine1>Detail line 1 value</DetailLine1>
<DetailLine2>detail line 2 value</DetailLine2>
</DETAIL>
</Items>
<Items>
<TN>ANOTHER VALUE 1</TN>
<TN2>SECOND VALUE 2</TN2>
<DETAIL>
<DetailLine1>Another value for detail line 1</DetailLine1>
<DetailLine2>second value for detail line 2 </DetailLine2>
</DETAIL>
</Items>
</Items>
</ORD>
</SDResult>
</SDResp>
</soap:Body>
</soap:Envelope>');
l_body := l_xmltype.extract('/soap:Envelope/soap:Body/*','xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"');
-- Change can * to the node name if always know it, If include it, need to include namespace as well.
l_index := 1;
WHILE l_body.Existsnode('/SDResp/SDResult/ORD/Items/Items[' || To_Char(l_index) || ']','xmlns="http://www.Aplace.com/processserver"') > 0
LOOP
lv_value := l_body.extract('/SDResp/SDResult/ORD/Items/Items[' || To_Char(l_index) || ']/TN/text()','xmlns="http://www.Aplace.com/processserver"').getStringVal();
dbms_output.put_line('Emp Name : '||lv_value);
l_index := l_index + 1;
END LOOP;
end;I know you will need to do more, but that covers the basics for everything you should need, such as getting TN2 and looping through all the DetailLine? records within each Items
Look in the FAQ in the upper right for how to use the { code } tag (no spaces) to retain formatting as shown above.
Similar Messages
-
Dbms_xslprocessor package problems in PL/SQL
Hi all :)
I was wondering if anyone has any ideas about this problem I'm having:
When using the dbms_xslprocessor in PL/SQL, I consistently get dropped connections when trying to either transform a document, or search a document via XPath. So, for instance, if I call dbms_xslprocessor.selectSingleNode('XPATH'), the connection will drop out with the following error (I'm calling a stored procedure here):
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Similar problems happen on XMLType.transform(stylesheet).
I've only managed to have this happen when transforming or searching documents that are not in the default (i.e., xmlns="") namespace, but I can't get rid of the namespace (too much other code is relying on it being there).
What's even stranger is that the XSLPROCESSOR package works, but DBMS_XSLPROCESSOR package does not. Unfortunately, the XSLPROCESSOR package doesn't seem to handle namespaces well, and inserts seemingly random namespace declarations in the transformation results (for instance, on the root element, it puts in "xmlns:xmlns='http://www.w3.org/2000/xmlns/'") or redeclares namespaces on nodes that already have that namespace defined for them by their parents. Namespace prefixes, too.
Does anybody have any ideas as to what this might be?
Thanks in advance,
ConstantineI should also mention that I'm ABSOLUTELY sure that the stylesheets I'm using for transformation are correct as of XSLT ver. 1.0 -- multiple external processors (Xalan and MSXML, specifically) give the correct result on the same stylesheet.
-
Dbms_xslprocessor problems in PL/SQL
Hi all :)
-- This is a cross-posting of a question I placed on the XMLDB forum, but there seems to be more activity here
-- Sorry about the duplicate
I was wondering if anyone has any ideas about this problem I'm having:
When using the dbms_xslprocessor in PL/SQL, I consistently get dropped connections when trying to either transform a document, or search a document via XPath. So, for instance, if I call dbms_xslprocessor.selectSingleNode('XPATH'), the connection will drop out with the following error (I'm calling a stored procedure here):
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Similar problems happen on XMLType.transform(stylesheet).
I've only managed to have this happen when transforming or searching documents that are not in the default (i.e., xmlns="") namespace, but I can't get rid of the namespace (too much other code is relying on it being there).
What's even stranger is that the XSLPROCESSOR package works, but DBMS_XSLPROCESSOR package does not. Unfortunately, the XSLPROCESSOR package doesn't seem to handle namespaces well, and inserts seemingly random namespace declarations in the transformation results (for instance, on the root element, it puts in "xmlns:xmlns='http://www.w3.org/2000/xmlns/'") or redeclares namespaces on nodes that already have that namespace defined for them by their parents. Namespace prefixes, too.
I should mention that I'm absolutely sure the stylesheet is correct. External processors like MSXML and Xalan produce correct results.
Does anybody have any ideas as to what this might be?
Thanks in advance,
Constantinewhat version of the XDK are you using ?
Version of the javaparser ? -
Error with dbms_xslprocessor.clob2file
Hi all!
I am experiencing an error with this command
dbms_xslprocessor.clob2file(v_xml,'DIR','1.xml');
where:
v_xml is a clob ( it is well formed and with data)
DIR is the directory where i want to output the data, it has beeen created with: EXECUTE IMMEDIATE 'create or replace directory DIR ' ||' as ' || '''D:\XMLFILES''';
and i don't have any error in this command
1.xml is the name of the file.
The errors i get when i execute that command are the following:
ORA-29283 invalid file operation
ORA-06512 at "SYS.UTL_FILE" line 451
ORA-29283 invalid file operation
ORA-06512 at "XDB.DBMS_XSlPROCESSOR" line 58
ORA-06512 at "DBA_TEST.PRUEBA_TEST" line 106
ORA-06512 at line 2
thx in advance!!!Hi, excuse me for taking so long time to respond, but yesterday i had a mayor issue to solve, but now i am again with this problem.
I'm gonna put some more code.
The database is in another location, and i want to write the data in a local drive, so maybe this is important for the code.
I will put the full code so maybe there is something else important here:
CREATE OR REPLACE PROCEDURE DBA_TEST.PRUEBA_TEST AS
v_select VARCHAR2(2000);
v_ctx DBMS_XMLGen.ctxHandle;
v_xml CLOB;
v_more BOOLEAN := TRUE;
xmldoc dbms_xmldom.DOMDocument;
DIR VARCHAR2(200);
v_DIR VARCHAR2(200);
BEGIN
EXECUTE IMMEDIATE 'create or replace directory DIR ' ||' as ' || '''D:\XMLFILES''';
v_DIR := DIR;
v_select := ' select nombre, direccion, dni from clientes where anio = 2009';
v_ctx := DBMS_XMLGen.newContext(v_select);
DBMS_XMLGen.setRowsetTag(v_ctx, 'rec_decla');
DBMS_XMLGen.setRowTag(v_ctx, '');
v_xml := DBMS_XMLGen.GetXML(v_ctx);
DBMS_XMLGen.closeContext(v_ctx);
dbms_xslprocessor.clob2file(v_xml,v_DIR,'1.xml');
DBMS_LOB.FREETEMPORARY(v_xml);
END;
Remeber that the data are in another location, no local, and i need to output these xml in the D:\XMLFILES directory.
I tried to grant permisions
GRANT READ, WRITE ON DIRECTORY TO DBA_USER
, but it said that i can't give permision to itself..
maybe there is another way to write these files witout using:
dbms_xslprocessor.clob2file(v_xml,v_DIR,'1.xml');
but i would like to use it.
Thx all!!! -
LPX-00601: Invalid token Error in DBMS_XSLPROCESSOR
Hi All,
I am using DBMS_XMLDOM and DBMS_XSLPROCESSOR to parse the XML file.
the following code was working fine in Release 10.1.0.4.0
l_n :=DBMS_XSLPROCESSOR.selectsinglenode
(xmldom.makenode (doc)
,'/tmf:MTOSI_InventoryData/tmf:mdList/tmf:md/tmf:tlList/tmf:tlInv/tmf:tlNm');
v_mux_id :=DBMS_XMLDOM.getnodevalue(DBMS_XMLDOM.getfirstchild (l_n));
BANNER
Oracle Database 10g Enterprise Edition Release 10.1.0.4.0 - 64bi
PL/SQL Release 10.1.0.4.0 - Production
CORE 10.1.0.4.0 Production
TNS for Solaris: Version 10.1.0.4.0 - Production
NLSRTL Version 10.1.0.4.0 - Production
But we have copied the same code in Release 10.2.0.2.0 i am getting the following error Plese do the needful
11:42:03 AM ORA-31011: XML parsing failed
11:42:03 AM : Error occurred in XML processing
11:42:03 AM LPX-00601: Invalid token in: '/tmf:MTOSI_InventoryData/tmf:mdList/tmf:md/tmf:tlList/tmf:tlInv/tmf:tlNm'
11:42:03 AM ORA-06512: at line 9
11:42:03 AM *** Script stopped due to error ***
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
PL/SQL Release 10.2.0.2.0 - Production
CORE 10.2.0.2.0 Production
TNS for Solaris: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
Plese do the needful
Thanks in Advance
ElanFUNCTION SELECTSINGLENODE RETURNS RECORD
Argument Name Type In/Out Default?
ID RAW(13) OUT
N RECORD IN
ID RAW(13) IN
PATTERN VARCHAR2 IN
NAMESPACE VARCHAR2 IN DEFAULTYou need to provide the namespace prefix mapping for the prefixes tmf via the NAMESPACE parameter (eg 'xmlns:tmf="xxxxxx"' -
Dbms_xslprocessor and namespaces
I'm using dbms_xslprocessor to transform xml to xml (well, more specifically, xml to rss)
My source document looks something like this:
<?xml version="1.0" encoding="iso-8859-1"?>
<feed xmlns:xa="http://host:port/portal/pls/portal/portal.wwsrc_app_xml.get_ctm_xsd">
<title>News News and More News</title>
<link>http://host:port/portal/pls/portal/</link>
<description><![CDATA[interesting news from around the world]]></description>
<base_url>http://host:port/portal/pls/portal/url/item/</base_url>
<copyright_year>2007</copyright_year>
<contact>[email protected]</contact>
<publish_date>Wed, 25 Jul 2007 12:25 -0400</publish_date>
<item>
<guid>2BC6636E56F7092AE0440003BA91D789</guid>
<display_name>News Story</display_name>
<publish_date>Fri, 16 Mar 2007 09:56 -0400</publish_date>
<description><![CDATA[including a >hyperlink in the description]]></description>
<xa:JohnsPageGroup_StoryPlacement>A</xa:JohnsPageGroup_StoryPlacement><xa:JohnsPageGroup_PhotoURL>2D4524A81D985FECE0440003BA91D789</xa:JohnsPageGroup_PhotoURL>
<category>Unassigned</category>
</item>
... and so on...
My XSLT (for the sake of discussion here... loaded as a varchar2):
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<rss version="2.0" xmlns:xa="http://host:port/portal/pls/portal/portal.wwsrc_app_xml.get_ctm_xsd">
<channel>
<title>
<xsl:value-of select="feed/title"/>
</title>
<link>
<xsl:value-of select="feed/link"/>
</link>
<language>en</language>
<copyright>Medical College of Georgia <xsl:value-of select="feed/copyright_year"/>
</copyright>
<managingEditor><xsl:value-of select="feed/contact"/></managingEditor>
<pubDate><xsl:value-of select="feed/publish_date"/></pubDate>
<image>
<title>Medical College of Georgia</title>
<url>http://www.mcg.edu/images/mcg100.gif</url>
<link>http://www.mcg.edu</link>
</image>
<xsl:for-each select="feed/item">
<item>
<title>
<xsl:value-of select="display_name"/>
</title>
<description>
<xsl:value-of select="description"/>
</description>
<link>
<xsl:value-of select="/feed/base_url" /><xsl:value-of select="guid"/>
</link>
<category>
<xsl:value-of select="category"/>
</category>
<guid>
<xsl:value-of select="/feed/base_url" /><xsl:value-of select="guid"/>
</guid>
<xsl:for-each select="xa:*">
<xsl:copy><xsl:apply-templates select="." /></xsl:copy>
</xsl:for-each>
</item>
</xsl:for-each>
</channel>
</rss>
</xsl:template>
</xsl:stylesheet>
Really, nothing fancy going on here (and relatively new to XSL folks, so constructive criticism is appreciated)... however...
The transformed content does not include the namespace attribute, nor do any of the source elements in the "xa" namespace appear in the output... e.g.
<rss version="2.0">
<channel>
<!-- snipped -->
<item>
<title>News Story</title>
<description>including a hyperlink in the description</description>
<link>http://mcgps10.mcg.edu:7784/portal/pls/portal/url/item/2BC6636E56F7092AE0440003BA91D789</link>
<category>Unassigned</category>
<guid>http://mcgps10.mcg.edu:7784/portal/pls/portal/url/item/2BC6636E56F7092AE0440003BA91D789</guid>
</item>
... etc....
When I run this transform in another environment--say, the NetBeans IDE--I get the expected output ("xmlns:xa=..." appears in the "rss" element, and "xa" elements appear below the "item" element).
What am I missing?
Thanks for the help.
-JohnI think I've traced this problem to how my original XML document was formed. I was actually using DBMS_XMLDOM to build the document, but when creating the text nodes, I couldn't specify a namespace for them, so I just called the element (for example) "xa:JohnsPageGroup_StoryPlacement".
Would the XSL processor see this DOM structure as I intended it?
Does 9.2 have a way to specify namespace when creating nodes. Am I hosed?
-John -
Dbms_xslprocessor ignore xsl:output
If I use the xslprocessor.processXsl the output is correct HTML
If I use dbms_xslprocessor.processXsl , in the output will be " replaced with quot; ...
it looks so that dbms_xslprocessor ignore tag <xsl:output method = "html"/>, or should I set output by other way ?
I've last patch 9.2.0.3.0 installed
I'm SunSPARC Solaris (64 bit) running
code fragment :
x_xsl_dom_document := Dbms_Xmldom.newDOMDocument (a_xslt);
x_style_sheet := dbms_xslprocessor.newStylesheet(x_xsl_dom_document, '');
x_processor := dbms_xslprocessor.newProcessor;
dbms_lob.createtemporary(x_tmp_clob, false, dbms_lob.call);
dbms_xslprocessor.processXsl(x_processor, x_style_sheet, a_xml, x_tmp_clob);Please post your question in XMLDB forum
-
Number 0.124 is written into file using dbms_xslprocessor.CLOB2File
Number 0.124 is written into file using dbms_xslprocessor.CLOB2File.
i have done dbmds_output and checked in the Clob content the value appears as .124 but in the file it appears as 124
Please help me to rectify this problem
Edited by: 796208 on Oct 7, 2010 4:55 AMYou shouldn't have the problem. Show some test cases.
SQL> CREATE TABLE test_clob (id NUMBER,clob_col CLOB);
Table created.
SQL> DECLARE
2 v_clob_locator CLOB;
3 v_clob CLOB;
4 BEGIN
5 INSERT INTO test_clob
6 VALUES
7 (1, EMPTY_CLOB())
8 RETURNING clob_col INTO v_clob_locator;
9 v_clob := 'This is test line
10 and it coniatns 0.124 and it seems that
11 .124 is not showing.';
12 dbms_lob.append(v_clob_locator, v_clob);
13 COMMIT;
14 END;
15 /
PL/SQL procedure successfully completed.
SQL> set long 10000
SQL> SELECT * FROM test_clob;
ID
CLOB_COL
1
This is test line
and it coniatns 0.124 and it seems that
.124 is not showing.
SQL> DECLARE
2 v_clob CLOB;
3 BEGIN
4 SELECT CLOB_COL INTO v_clob
5 FROM test_clob
6 WHERE id=1;
7 DBMS_XSLPROCESSOR.clob2file(v_clob,'TEST_DIR','clobtest.txt',0);
8 END;
9 /
PL/SQL procedure successfully completed.
SQL>
C:\>type clobtest.txt
This is test line
and it coniatns 0.124 and it seems that
.124 is not showing.
C:\>The only thing is the last parameter (Character set id). -
Dbms_xslprocessor return node copy
Recently I converted my code from sys.xmldom and sys.xslprocessor packages to xdb.dbms_xmldom and xdb.dbms_xslprocessor packages. And what supprised me is that dbms_xslprocessor.selectSingleNode() returns a copy of the selected node not a reference. My code was able to modify the xml tree before now failed. Is there a fix to this bug? I am using 9.2.0.5 patch. Thanks.
Hi,
Even I tried with variable based indexing
But for me its returing all nodes irrespective of index varible value -
DBMS_XSLPROCESSOR.SETPARAM problem
When I try to pass values of global parameters of stylesheet with DBMS_XSLPROCESSOR.SETPARAM I get "ORA-31020: The operation is not allowed, Reason: Invalid XSL Parameter or its Value". Can someone provide me with working example, please?
Database version Oracle XE 11g 11.2.0.2.0This works for me :
SQL> set serveroutput on
SQL>
SQL> DECLARE
2
3 p dbms_xslprocessor.Processor;
4 s dbms_xslprocessor.Stylesheet;
5
6 xsldoc clob := '<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
7 <xsl:output method="xml"/>
8 <xsl:param name="test"/>
9 <xsl:template match="/">
10 <result><xsl:value-of select="$test"/></result>
11 </xsl:template>
12 </xsl:stylesheet>';
13
14 xmlresult varchar2(4000);
15
16 BEGIN
17
18 p := dbms_xslprocessor.newProcessor;
19 s := dbms_xslprocessor.newStylesheet(dbms_xmldom.newDOMDocument(xsldoc), null);
20 dbms_xslprocessor.setParam(s, 'test', '"Hello!"');
21
22 dbms_xslprocessor.processXSL(p, s, dbms_xmldom.newDOMDocument('<dummy/>'), xmlresult);
23
24 dbms_xslprocessor.freeStylesheet(s);
25 dbms_xslprocessor.freeProcessor(p);
26
27 dbms_output.put_line(xmlresult);
28
29 END;
30 /
<?xml version="1.0" encoding="utf-8"?>
<result>Hello!</result>
PL/SQL procedure successfully completed -
DBMS_XSLPROCESSOR and xsl:import
Hi all!
I'm using Oracle 9.2 and DBMS_XSLPROCESSOR to transform my XML to HTML.
I build XML using DBMS_XMLDOM methods, build stylesheet using dbms_xslprocessor.newstylesheet,
then try to transform it using DBMS_XSLPROCESSOR.processXSL.
It work fine. But if I add <xsl:import href="http://server/myPackage.getXSL"/>
(myPackage.getXSL return another XSL) to my original xsl file, then dbms_xslprocessor.newstylesheet
function fails with error:
[1]: (Error): ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00412:
Message 412 not found; product=XDK; facility=LPX ORA-06512: at "XDB.DBMS_XSLPROCESSOR",
line 467 ORA-06512: at "XDB.DBMS_XSLPROCESSOR" ...
Does anybody have any ideas what is wrong ?
Thanks in advance,
Gregory.Hi all!
I'm using Oracle 9.2 and DBMS_XSLPROCESSOR to transform my XML to HTML.
I build XML using DBMS_XMLDOM methods, build stylesheet using dbms_xslprocessor.newstylesheet,
then try to transform it using DBMS_XSLPROCESSOR.processXSL.
It work fine. But if I add <xsl:import href="http://server/myPackage.getXSL"/>
(myPackage.getXSL return another XSL) to my original xsl file, then dbms_xslprocessor.newstylesheet
function fails with error:
[1]: (Error): ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00412:
Message 412 not found; product=XDK; facility=LPX ORA-06512: at "XDB.DBMS_XSLPROCESSOR",
line 467 ORA-06512: at "XDB.DBMS_XSLPROCESSOR" ...
Does anybody have any ideas what is wrong ?
Thanks in advance,
Gregory. -
Dbms_xslprocessor.valueOf generates ora-24331
I am using 10.1.0.3.0 Oracle standard database. I am using dbms_xslprocessor to parse document. I get ora-24331.
FOR rec2 IN 0 .. dbms_xmldom.getLength(l_nl) - 1 LOOP
l_n := dbms_xmldom.item(l_nl, rec2);
-- Use XPATH syntax to assign values to he elements of the collection.
dbms_xslprocessor.valueOf(l_n,'DATA/RECORD_TYPE[1]/text()',rectype);
dbms_xslprocessor.valueOf(l_n,'DATA/MAIN_ENTRY[1]/text()',mainentry);
dbms_xslprocessor.valueOf(l_n,'DATA/URL[1]/text()',url);
dbms_xslprocessor.valueOf(l_n,'DATA/TITLE[1]/text()',title);
dbms_xslprocessor.valueOf(l_n,'DATA/DESCRIPTION[1]/text()',description);
dbms_xslprocessor.valueOf(l_n,'DATA/SIMILAR-PAGES-URL[1]/text()',similaPageURL);
dbms_xslprocessor.valueOf(l_n,'DATA/MUSE_SESSION_UID[1]/text()',musesessionid);
dbms_xslprocessor.valueOf(l_n,'IDR/TITLE[1]/text()',IDRTITLE);
dbms_xslprocessor.valueOf(l_n,'DATA/MUSE_SESSION_UID[1]/text()',musesessionid);
dbms_xslprocessor.valueOf(l_n,'IDR/IDENTIFIER[1]/text()',idr_Identifier);
dbms_xslprocessor.valueOf(l_n,'IDR/DESCRIPTION[1]/text()',idr_description);
INSERT INTO DOJ_DATA(INSTRUCTION_ID , REFERENCE_ID,RESULT_SET_NAME, RECORD_TYPE,MAIN_ENTRY,URL,
TITLE ,DESCRIPTION,SIMILAR_PAGES_URL,MUSE_SESSION_UID,
RAWDATA,IDR_TITLE ,IDR_IDENTIFIER ,IDR_DESCRIPTION)
VALUES(insructionid,ref_id,result_set_name,rectype,mainentry,url,title,description,similaPageURL,
musesessionid,rawdata,IDRTITLE,idr_Identifier,idr_description);
commit;
END LOOP;
dbms_xmldom.freeDocument(doc);
dbms_xmlparser.freeParser(l_parser);Well, since you are probably trying to return more data than the varchar2 return parameter allows, you need to switch methods for how you are extracting data from the XML.
Three sample methods can be found in the sample at Re: ORA-20100: Error while parsing:Error opening external DTD Urgent -
Parsing attribute value using dbms_xslprocessor
Hi,
We have a xmltype column which has the following structure :
<?xml version="1.0" encoding="utf-16"?>
<myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30">
<PayToTheOrderOf>TESTING</PayToTheOrderOf>
<AllocationList>
<Allocation d3p1:LineNum="0" xmlns:d3p1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30">
<d3p1:Name>ANNE PETER</d3p1:Name>
<d3p1:StreetAddress2>600 N WEST ST</d3p1:StreetAddress2>
<d3p1:City>BALTIMORE</d3p1:City>
<d3p1:State>MD</d3p1:State>
</Allocation>
<Allocation d3p1:LineNum="1" xmlns:d3p1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30">
<d3p1:Name>DAVID GREY</d3p1:Name>
<d3p1:StreetAddress2>EAST AVE</d3p1:StreetAddress2>
<d3p1:City>4</d3p1:City>
<d3p1:State>MD</d3p1:State>
</Allocation>
</myFields>"
Can anyone tell me how to parse the attribute value from the tag, "Allocation". Example: I would like to get the value from "LineNum" attribute. I would like to use dbms_xslprocessor in pl/sql.
Thanks in advance.DECLARE
l_return xmltype;
l_num VARCHAR2 (10);
l_namespace1 VARCHAR2(200) := 'xmlns="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30"';
l_namespace2 VARCHAR2(200) := 'xmlns:d3p1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30"';
l_parser dbms_xmlparser.parser;
l_doc dbms_xmldom.domdocument;
l_nl dbms_xmldom.domnodelist;
l_n dbms_xmldom.domnode;
BEGIN
SELECT xmltype('<?xml version="1.0" encoding="utf-16"?>
<myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xml:lang="en-us" xmlns="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30">
<PayToTheOrderOf>TESTING</PayToTheOrderOf>
<AllocationList>
<Allocation d3p1:LineNum="0" xmlns:d3p1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30">
<d3p1:Name>ANNE PETER</d3p1:Name>
<d3p1:StreetAddress2>600 N WEST ST</d3p1:StreetAddress2>
<d3p1:City>BALTIMORE</d3p1:City>
<d3p1:State>MD</d3p1:State>
</Allocation>
<Allocation d3p1:LineNum="1" xmlns:d3p1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-05-06T14:08:30">
<d3p1:Name>DAVID GREY</d3p1:Name>
<d3p1:StreetAddress2>EAST AVE</d3p1:StreetAddress2>
<d3p1:City>4</d3p1:City>
<d3p1:State>MD</d3p1:State>
</Allocation>
</AllocationList>
</myFields>')
INTO l_return
FROM dual;
l_parser := dbms_xmlparser.newParser;
dbms_xmlparser.parseClob(l_parser, l_return.getclobval());
l_doc := dbms_xmlparser.getDocument(l_parser);
dbms_xmlparser.freeParser(l_parser);
l_nl := dbms_xslprocessor.selectNodes(dbms_xmldom.makeNode(l_doc),'/myFields/AllocationList/Allocation', l_namespace1);
FOR i IN 1 .. dbms_xmldom.getLength(l_nl) LOOP
l_n := dbms_xmldom.item(l_nl, i-1);
dbms_xslprocessor.valueOf(l_n,'@d3p1:LineNum',l_num, l_namespace2);
dbms_output.put_line(l_num);
END LOOP;
dbms_xmldom.freeDocument(l_doc);
END; -
Creating PDF documents using DBMS_XSLPROCESSOR ??
Hi everybody,
I have my XML document and my stylesheet in DB and i'm trying to create a PDF document using the DBMS_XSLPROCESSOR.processxsl method, can anybody help me about that ??
Thanks for your help...
Lionel from SwitzerlandFor desktop-based solutions, look at the Adobe Acrobat SDK which enables development around Acrobat itself. Or if you wish a stand-alone solution (for either desktop or server), we offer the Adobe PDFLibrary, which is the same technology used by all of Adobe's applications.
For the server, we have our LiveCycle products including LC Generator.
Leonard -
Dbms_xslprocessor oracle R2 10.2
Someone knows the differences between Oracle db 10.1 and 10.2 in dbms_xslprocessor?.
This pck works ok in 10.1 but in 10.2 the system show up an error:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00240: element-start tag is not well formed
Do you know if exist a difference on this pck between the oracle versions?
Thanks.
Diego.
Edited by: DIEG0 on 25-feb-2009 10:20Hello,
Check following document on metalink
Doc ID: 6952870.8 see if this resolves your problem (bug related).
Regards
Maybe you are looking for
-
ITunes keeps crashing on my Dell PC.
iTunes keeps crashing on my Dell PC with Windows Vista. I have already uninstalled and reinstalled- didn't help. iTunes will open, but then crashes after about two or three minutes, no matter what I'm doing with it at the time. Any ideas? Could a la
-
Vendor/customers clearing against eachother.
Hi Gurus, We have a scenario where, one plant (P1) is selling FG to other (P2). P2 is treated as customer and P1 as vendor within the same company code. My doubt is, can we adjust/clear entries belonging to this transaction against customer and vendo
-
Images in css vs images in html
Is there any benefit over placing an image (which will be used in a template, so all pages on the site), as a background image on the css stylesheet as opposed to having it on the html in each page? Example: CSS: #logo { background: url(logo.jpg) no-
-
Error while configuring system preparation in solman step 5.6(configure SAPconnect)
Hello, We have recently upgrade solman from SP4 to SP 11. I am doing reconfiguration of the Solman. Stuck in one step of system preparation ->Step 5 Configure Connectivity -> 5.6 Configure SAPconnect. The error which i am facing is "Email address cou
-
Transaction MMCL does not work in ECC 6.0 system
Hello All, I am trying to run transaction MMCL in ECC 6.0 system. It does not run. Has SAP obsoleted this transaction and come up with a new one. Basically I want to track inventory based on a Batch Characteristic value. Thanks in advance, Sachin