Oracle error when parsing XML data: LPX-00663 - oracle

Im getting below error, can anyone please help me resolve it.
the ORA-31011: the XML parsing failed The  the ORA-19202: the Error
Occurred in the XML processing support  The LPX-00663:. VM
String-Stack overflow
I could see solution as Increase the size bed of the VM StringStack in XmlXslVMCreate ()  in some websites but no steps given on how to do it.

From Oracle Documentation.
PL/SQL package DBMS_XSLPROCESSOR provides a convenient and efficient
way of applying a single style sheet to multiple documents. The
performance of this package is better than that of method transform(),
because the style sheet is parsed only once.
I had the same problem. Workaround was. Something like this.
DECLARE
v_out_clob CLOB;
v_in_xml XMLTYPE;
v_in_xsl XMLTYPE;
ctx_xslproc dbms_xslprocessor.processor;
v_in_xsl_dd dbms_xmldom.DOMDocument;
v_in_xml_dd dbms_xmldom.DOMDocument;
v_styleshet dbms_xslprocessor.stylesheet;
BEGIN
v_in_xml := new xmltype('<?xml version="1.0" encoding="ISO-8859-1"?><document></document>');
v_in_xsl := new xmltype('<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<script type="text/javascript" src="jquery-1.11.1.min.js"></script>
</head>
<body>
<br />
</body>
</html>
</xsl:template>
</xsl:stylesheet>');
ctx_xslproc := dbms_xslprocessor.newProcessor;
v_in_xsl_dd := dbms_xmldom.newDOMDocument(v_in_xsl);
v_in_xml_dd := dbms_xmldom.newDOMDocument(v_in_xml);
v_styleshet := dbms_xslprocessor.newStyleSheet(v_in_xsl_dd, NULL);
dbms_lob.createtemporary(v_out_clob,FALSE);
dbms_xslprocessor.processXSL(ctx_xslproc,v_styleshet,v_in_xml_dd,v_out_clob);
dbms_xmldom.freeDocument(v_in_xsl_dd);
dbms_xmldom.freeDocument(v_in_xml_dd);
dbms_xslprocessor.freeProcessor(ctx_xslproc);
dbms_output.put_line(v_out_clob);
END;

Related

apache fop 2.7 with spring boot 2.7.1 getting failed to generate pdf [duplicate]

I am generating a PDF document with XML file as input using Apache FOP 2.4.
To prevent XXE-Attacks I need to set the secure processing feature (FEATURE_SECURE_PROCESSING) in TransformerFactory:
InputStream xslTransformer = getClass().getClassLoader().getResourceAsStream("foo.xsl");
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformerFactory.setFeature(FEATURE_SECURE_PROCESSING, true);
Transformer transformer = transformerFactory.newTransformer(new StreamSource(xslTransformer));
transformer.transform(new DOMSource(), new SAXResult(fop.getDefaultHandler()));
After setting this feature I can't generate any PDF document and I'm getting warnings:
SystemId Unknown; Line #49; Column #99; "master-name" attribute is not allowed on the fo:simple-page-master element!
SystemId Unknown; Line #49; Column #99; "initial-page-number" attribute is not allowed on the fo:simple-page-master element!
SystemId Unknown; Line #49; Column #99; "page-height" attribute is not allowed on the fo:simple-page-master element!
SystemId Unknown; Line #49; Column #99; "page-width" attribute is not allowed on the fo:simple-page-master element!
etc ...
Here is a section of XSL file (foo.xsl):
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:pdf="http://xmlgraphics.apache.org/fop/extensions/pdf">
<xsl:template match="/">
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="A4-portrait" initial-page-number="1"
page-height="29.7cm" page-width="21.0cm" margin-top="0cm"
margin-left="1cm" margin-right="1.3cm" margin-bottom="0cm">
<fo:region-body margin-top="2.2cm" margin-bottom="1.2cm" margin-left="1.3cm"/>
<fo:region-before region-name="xsl-region-before" extent="2.2cm"/>
<fo:region-after region-name="xsl-region-after" extent="1.2cm"/>
<fo:region-start region-name="xsl-region-start" extent="1.3cm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="A4-portrait" font-family="Consolas" font-size="11">
<fo:flow flow-name="xsl-region-body">
<fo:block linefeed-treatment="preserve" font-weight="bold">
foo
</fo:block>
<fo:block linefeed-treatment="preserve">
bar
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>
</xsl:stylesheet>
How should I use this feature and make it work? Java version is 8.
This is due to xalan-2.7.2.
Here is the bug in Xalan-J
Switching to xalan-2.7.1 or earlier will solve your problem.
You may have to force exclusions for xalan on an Apache-FO dependency.
You can also overwrite with 2.7.2_3, which patches this problem.
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.xalan</artifactId>
<version>2.7.2_3</version><!--$NO-MVN-MAN-VER$-->
</dependency>
Use of <!--$NO-MVN-MAN-VER$--> prevents overrides.

Extract data from XMLTYPE variable

I have an XML below from which I am trying to extract the error tag data:
<ns1:updateStatusResponse xmlns:ns1="http://www.example.com/webservices">
<return href="#ID1"/>
</ns1:updateStatusResponse>
<ns3:OrderStatusUpdateResponse xmlns:ns3="http://www.example.com/com.example.com.ful.mod" id="ID1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:OrderStatusUpdateResponse">
<status xsi:type="xsd:string">ERROR</status>
<statusDetail xsi:type="xsd:string">Error occured when updating status for example</statusDetail>
</ns3:OrderStatusUpdateResponse>
I am using a logic like this, where resp is XMLTYPE and v_resp is VARCHAR2
v_resp := resp.EXTRACT (
'ns3:OrderStatusUpdateResponse/status/text()',
'xmlns:ns3="http://http://www.example.com/com.example.com.ful.mod" id="ID1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ns3:OrderStatusUpdateResponse').getstringval ();
Whenever I run this in my code, I get an exception but no message.
Can someone please help me resolve this?

Nokogiri parsing through XML fails

The code:
response = Nokogiri::XML(open('https://geocode-maps.yandex.ru/1.x/?geocode=%D0%A1%D0%B0%D0%BD%D0%BA%D1%82-%D0%9F%D0%B5%D1%82%D0%B5%D1%80%D0%B1%D1%83%D1%80%D0%B3+%D0%A1%D0%B2%D0%B5%D1%80%D0%B4%D0%BB%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F+%D0%BD%D0%B0%D0%B1%D0%B5%D1%80%D0%B5%D0%B6%D0%BD%D0%B0%D1%8F+44%D0%A2'), nil, Encoding::UTF_8.to_s)
lowerCorner = response.xpath("//lowerCorner")
XML document I parse is like:
<?xml version="1.0" encoding="utf-8"?>
<ymaps xmlns="http://maps.yandex.ru/ymaps/1.x" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://maps.yandex.ru/business/1.x http://maps.yandex.ru/schemas/business/1.x/business.xsd http://maps.yandex.ru/geocoder/1.x http://maps.yandex.ru/schemas/geocoder/1.x/geocoder.xsd http://maps.yandex.ru/psearch/1.x http://maps.yandex.ru/schemas/psearch/1.x/psearch.xsd http://maps.yandex.ru/search/1.x http://maps.yandex.ru/schemas/search/1.x/search.xsd http://maps.yandex.ru/web/1.x http://maps.yandex.ru/schemas/web/1.x/web.xsd http://maps.yandex.ru/search/internal/1.x http://maps.yandex.ru/schemas/search/internal/1.x/internal.xsd">
<GeoObjectCollection>
<metaDataProperty xmlns="http://www.opengis.net/gml">
<GeocoderResponseMetaData xmlns="http://maps.yandex.ru/geocoder/1.x">
<request>Санкт-Петербург Свердловская набережная 44Т</request>
<found>1</found>
<results>10</results>
</GeocoderResponseMetaData>
</metaDataProperty>
<featureMember xmlns="http://www.opengis.net/gml">
<GeoObject xmlns="http://maps.yandex.ru/ymaps/1.x" xmlns:gml="http://www.opengis.net/gml" gml:id="1">
<metaDataProperty xmlns="http://www.opengis.net/gml">
<GeocoderMetaData xmlns="http://maps.yandex.ru/geocoder/1.x">
<kind>house</kind>
<text>Россия, Санкт-Петербург, Свердловская набережная, 44Т</text>
<precision>exact</precision>
</GeocoderMetaData>
</metaDataProperty>
<Envelope>
<lowerCorner>30.397902 59.959183</lowerCorner>
<upperCorner>30.406113 59.9633</upperCorner>
</Envelope>
</boundedBy>
<Point xmlns="http://www.opengis.net/gml">
<pos>30.402008 59.961242</pos>
</Point>
</GeoObject>
</featureMember>
</GeoObjectCollection>
</ymaps>
I'd like to get lowerCorner, but nothing from official and others sources does work:
response.xpath('//lowerCorner')
response.search('//lowerCorner')
response.xpath('xmlns:lowerCorner')
response.xpath('xmlns:lowerCorner', ns).text
response.css('lowerCorner')
The only result is: []
So how to parse lowerCorner's content?
Removing the namespaces (or using them in your path) should help.
Try this:
require "nokogiri"
require "open-uri"
response = Nokogiri::XML(open('https://geocode-maps.yandex.ru/1.x/?geocode=%D0%A1%D0%B0%D0%BD%D0%BA%D1%82-%D0%9F%D0%B5%D1%82%D0%B5%D1%80%D0%B1%D1%83%D1%80%D0%B3+%D0%A1%D0%B2%D0%B5%D1%80%D0%B4%D0%BB%D0%BE%D0%B2%D1%81%D0%BA%D0%B0%D1%8F+%D0%BD%D0%B0%D0%B1%D0%B5%D1%80%D0%B5%D0%B6%D0%BD%D0%B0%D1%8F+44%D0%A2'), nil, Encoding::UTF_8.to_s)
response.remove_namespaces! # <<<<<<<
lower_corner = response.xpath("/ymaps/GeoObjectCollection/featureMember/GeoObject/boundedBy/Envelope/lowerCorner").first
p lower_corner.text #> "30.397902 59.959183"

dbms_xmldom - How to get the <?xml tag

I am trying to get the line <?xml ....?> at the start of the XML document using the PL/SQL Package dbms_xmldom. Here is the code so far
declare
l_dom dbms_xmldom.DOMDocument;
l_clob clob;
l_node dbms_xmldom.DOMNode;
begin
l_dom := dbms_xmldom.newDomDocument;
l_node := dbms_xmldom.makeNode(l_dom);
l_node := dbms_xmldom.appendChild(l_node,
dbms_xmldom.makeNode(
dbms_xmldom.createElement(l_dom, 'root')
)
);
dbms_lob.createtemporary(l_clob, true);
dbms_xmldom.writeToClob(l_dom, l_clob);
dbms_output.put_line(l_clob);
end;
The output is:
<root/>
Expect:
<?xml version="1.0" encoding="UTF-8"?>
<root/>
Any pointers on how to do this would get great.
Just for the record - here is what you need to add
dbms_xmldom.setVersion(l_dom, '1.0" encoding="UTF-8');
after creating the document
The prolog is usually added automatically by XML serialization, so you shouldn't need to add it yourself, but if you want to you can with XMLRoot.
Your method for generating XML is quite inefficient. You should be looking at XMLElement, XMLForest, XMLAgg etc.
Here's a simple root and child example, with prolog in one line of code.
select XMLRoot(XMLElement("root", XMLElement("child", 12)), version '1.0') from dual
<?xml version="1.0"?>
<root>
<child>12</child>
</root>

Reading xml nodes using VB script

I have an xml file that I want to read using VBScript (Technology limitation). Below is the code and xml file. I am able to read the file if there is no DTD element involved but the code doesn't work for file having DTD and xml-style element.
Code-
Dim xmlDoc1:Set xmlDoc1 = CreateObject("MSXML2.DomDocument")
xmlDoc1.async=False
xmlDoc1.load "C:\ABC.xml"
Dim xmlTCID:Set xmlTCID = xmlDoc1.selectNodes("//*")
For nNodeCount = 0 To xmlTCID.length
MsgBox(xmlTCID(nNodeCount).nodeName)
Next
ABC.xml -
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE RESULT SYSTEM "Result.dtd"[]>
<?xml-stylesheet type="text/xsl" href="Result.xsl"?>
<SUMMARY>
<TITLE>Test</TITLE>
</SUMMARY>
<IDS>
<DATA>
<NAME>A</NAME>
<VALUE>PASS</VALUE>
</DATA>
<DATA>
<NAME>B</NAME>
<VALUE>PASS</VALUE>
</DATA
<DATA>
<NAME>C</NAME>
<VALUE>FAIL</VALUE>
</DATA
</IDS>
<IDS>
<DATA>
<NAME>A</NAME>
<VALUE>PASS</VALUE>
</DATA>
<DATA>
<NAME>B</NAME>
<VALUE>FAIL</VALUE>
</DATA
</IDS>
Note - If I avoid -
<!DOCTYPE RESULT SYSTEM "Result.dtd"[]>
<?xml-stylesheet type="text/xsl" href="Result.xsl"?>
The above code is able to read the nodes but with the above two lines in xml file, it gives the below error -
Requirement - I need to read the name of last DATA node with FAIL for each IDS node.
Any suggestion as what to do to get the code working even with -
<!DOCTYPE RESULT SYSTEM "Result.dtd"[]>
<?xml-stylesheet type="text/xsl" href="Result.xsl"?>
As there are problems with your XML - more than one top level element, miising ">" - setting the ProhibitDTD Property to False won't solve all of your tasks.
xmlDoc.validateOnParse=False
worked for me.

Resources