Parsing in Java
Hey Guys,
I have a requirement where i need to read and validate a fixed length text file having 90,000 records(lines). I need to parse each record and do some validations. Currently i am reading line by line using regular java.io.FILE/java.io.FileInputStream etc and parsing and validating the tokens. It takes around 15-20 minutes. Is there a better way to do it in java.
Any ideas??
Thanks
KM
I wanted to know if there is something like lexical analysis / parsing in javaI believe thats what JavaCC is for, although I have never used it. Search the forum using "JavaCC" as the keyword or search google. I'm sure you'll find more information.
15-20 minutes sounds like a long time to parse and tokenize a string. I was playing with StringTokenizer and created a 200 character string that contained 10 tokens. I tokenized this string 200,000 times and it only took 4 seconds.
Similar Messages
-
ANN: Oracle XML Parser for Java v2.0.0.1
A new maintenance release of the Oracle Parser for Java is
available for download. It has the following fixes and changes:
Bug fixes for #920536, i.e. Cannot access element attributes via
XSLT; #898423. i.e. ElementDecl's in DTDs; #774774, i.e. DOM
extensions using XSL pattern matching; #863890 i.e. SAX
IOException not thrown.
New APIs in the following new interface:
1. oracle.xml.parser.v2.NSResolver
- resolveNamespacePrefix( find the namespace definition in scope
for a given namespace prefix )
New APIs in the following classes:
1. oracle.xml.parser.v2.XMLNode
- selectNodes( Selects nodes from the tree which match the given
pattern; client can provide an NSResolver implementation to
resolve namespace prefixes in the pattern ).
2. oracle.xml.parser.v2.ElementDecl
- getParseTree( Returns the root Node of Content Model parse
tree, which could then be traversed node by node using
getFirstChild() and getLastChild(). The Node types are: PLUS,
COMMA, ASTERISK, ELEMENT, QMARK ).
This is the first beta patch release for v2.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
nullunzip -l appsborg2.zip | grep 9.0.4
0 04-18-03 20:10 .xdkjava_version_9.0.4.0.0_production
do i still need to do that step?No, you do not have to since "XML Parser for Java v9.0.4" is already installed as part of appsborg2.zip -
ANN: XML Parser for Java v2.0.2.6
The v2.0.2.6 of the XML Parser for Java is now available for download. The following features and bug fixes are included:
Changes:
Conformance to the XSLT/XPATH October REC.
New API in XSLStylesheet class:
removeParam(String param)
resetParams()
Bug fixes:
Bug #1111423: OutOfMemory exception, if multiple calls made to document()
Bug #1101028: Unexpected character error in DTD parsing document using Docbook DTD
Bug #1101021: #default not supported in exclude-result-prefixes
Bug #1099830: Extra characters inserted into output using the XML Parser
Bug #1099663: HTML output does not allow only doctype-public to be specified
Bug #1099536: HTML output does not disable escaping for script, style unless lowercase
Bug #1098738: ArrayOutOfBoundsException xsl:if test="not(@a)'"
Bug #1095047: XSLProcessor NPE'S on named templates with non-empty namespaces
Bug #1094971: XSLStylesheet needs methods for removing parameters
Bug #1092351: Using valueof() shuffles order of elements in my source document
Bug #1086663: xsl:sort data-type attribute can now be a namespace-prefixed name
Bug #1086661: xsl:version attribute now required on literal result element
Bug #1064692: Default xml-serialization should use empty-element syntax
Bug #1064689: Current() function doesn't work correctly
This is the sixth production patch release for v2.
Oracle XML Team http://technet.oracle.com
Oracle Technology Network
nullThe link has been fixed. You will go to the v2 download page
now. Sorry for the inconvience.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Renilton Oliveira (guest) wrote:
: I didn't find the file for version 2.0.0.0 as well.
: Renilton
: Andrei Filimonov (guest) wrote:
: : I tried to download XML Parser for Java v2 it seems that
only
: v
: : 1.0.1.4 is available. Could you please give an exact URL for
: v2
: : download?
: : Andrei Filimonov
: : Oracle XML Team wrote:
: : : The Oracle XML v2 parser is now available for download
here
: as
: : : an early beta release and is written in Java. It features
: an
: : : improved architecture over the Oracle XML v1 parser and
has
: : : shown better performance on small to large XML documents.
: It
: : : will also be able to format the XML document according to
a
: : : stylesheet, having integrated an XSLT processor.
: : : Version 2 of the XML Parser for Java, besides
incorporating
: an
: : : XSLT processor, has been re-architected from version 1.
This
: : has
: : : resulted in a number of changes to the class names
: especially
: : : those that support Namespaces. See v2changes.txt and
: the .diff
: : : difference files in the sample directory.
: : : Oracle XML Team
: : : http://technet.oracle.com
: : : Oracle Technology Network
null -
Parse Exception : java.text.ParseException: Unparseable date
I have inherited a UDF in some mapping that on the whole, works okay...
but it throws an error after mapping a few dates:
Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
Parse Exception : java.text.ParseException: Unparseable date: "2010-03-18T00:00:00.000Z"
Parse Exception : java.text.ParseException: Unparseable date: "2010-03-23T23:59:00.000Z"
the first few map okay... then i get the exception.
the UDF is as follows:
public String convertDateTimeToUTC(String strDate, Container container) throws StreamTransformationException{
AbstractTrace trace = container.getTrace();
Date date=null;
SimpleDateFormat sdfSource = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
try{
String dt = strDate;
date = sdfSource.parse(dt);
trace.addInfo("Local Date:"+date);
SimpleDateFormat sdfDestination = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
strDate = sdfDestination.format(date);
catch(ParseException pe){
trace.addInfo("Parse Exception : " + pe);
return strDate;
can anyone see why this fails after successfully mapping a few fields???the first mapping works correctly...
then we reuse the same fields to map to the additional segments.
the context is correct as it is trying to pull the same fields in... it just throw the error with the same data in the same UDF/Function Library but for different segments! :o(
http://img199.imageshack.us/img199/3104/dateconversion.jpg
as you can see from the screenshot above, the mapping works in the first instance, then fails on subsequent nodes. -
ORACLE XML PARSER FOR JAVA FOR AIX
Hi people!
I'm looking for the Oracle XML Parser for Java 9.0.2.0.0C, my 9iAS is BI Installation 9.0.2.3, where can I get it? In the Downloads Section there is only the version for 10g, and the existing versions for 9i are not for AIX (my OS is AIX 5.2L).
Thanks.Thanks for your help, I navigate through this link and, even it shows a table where appears the release for AIX (9.2.0.6.0), when I get to http://www.oracle.com/technology/tech/xml/xdk/software/prod/utilsoft_java.htm
it shows me only downloads for Sun, Linux and HP-UX, but not for AIX.
Has the version for AIX being deprecated or something like that? -
Parsing an XML using DOM parser in Java in Recursive fashion
I need to parse an XML using DOM parser in Java. New tags can be added to the XML in future. Code should be written in such a way that even with new tags added there should not be any code change. I felt that parsing the XML recursively can solve this problem. Can any one please share sample Java code that parses XML recursively. Thanks in Advance.
Actually, if you are planning to use DOM then you will be doing that task after you parse the data. But anyway, have you read any tutorials or books about how to process XML in Java? If not, my suggestion would be to start by doing that. You cannot learn that by fishing on forums. Try this one for example:
http://www.cafeconleche.org/books/xmljava/chapters/index.html -
Parsing xml using DOM parser in java
hi there!!!
i don have much idea about parsing xml.. i have an xml file which consists of details regarding indentation and spacing standards of C lang.. i need to read the file using DOM parser in java n store each of the attributes n elements in some data structure in java..
need help as soon as possible!!!DOM is the easiest way to parse XML document, google for JDOM example it is very easy to implement.
you need to know what is attribute, what is text content and what is Value in XML then easily you can parse your document with dom (watch for space[text#] in your XML document when you parse it).
you get root node then nodelist of childs for root then go further inside, it is easy believe me. -
ANN: XML Parser for Java v2.0.2.5
The v2.0.2.5 of the XML Parser for Java is now available for
download. The following features and bug fixes are included:
Conformance to the XSLT/XPATH October PR.
Support for internationalized error messages has been added. The
locale can be set using setLocale(java.util.Locale) function in
XSLProcessor, SAXParser, and DOMParser.
New APIs in XMLNode class:
value-of(String pattern)
selectNodes(String pattern)
selectSingleNode(String pattern)
selectSingleNode(String pattern, NSResolver ns)
New API in XSLStylesheet class
setParam(String param, String value)
Bug fixes:
Bug #957465: Missing a way to set stylesheet-level param-
variables
Bug #962290: selectNodes() improvements
Bug #1033472: Html output prints empty elements for non-empty
elements
Bug #1040717: Character entity for greater that in html output
style
Bug #1046003: Bug is parsing text nodes larger than 16K
Bug #1051671: 'xsl:namespace-alias' not supported
Bug #1052387: Disable-output-escaping doesn't flush while
printing
Bug #1053273: 'xsl:message' terminate attribute not supported
Bug #1058004: No access to media-type and encoding on xsl:output
Bug #1058008: xsl:version attribute not copied to result
Bug #1061159: Exclude-result-prefixes not supported
Bug #1067965: Bug in Non-validating parser while reading QNames
in DTD
This is the fifth production patch release for v2.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
nullThe link has been fixed. You will go to the v2 download page
now. Sorry for the inconvience.
Oracle XML Team
http://technet.oracle.com
Oracle Technology Network
Renilton Oliveira (guest) wrote:
: I didn't find the file for version 2.0.0.0 as well.
: Renilton
: Andrei Filimonov (guest) wrote:
: : I tried to download XML Parser for Java v2 it seems that
only
: v
: : 1.0.1.4 is available. Could you please give an exact URL for
: v2
: : download?
: : Andrei Filimonov
: : Oracle XML Team wrote:
: : : The Oracle XML v2 parser is now available for download
here
: as
: : : an early beta release and is written in Java. It features
: an
: : : improved architecture over the Oracle XML v1 parser and
has
: : : shown better performance on small to large XML documents.
: It
: : : will also be able to format the XML document according to
a
: : : stylesheet, having integrated an XSLT processor.
: : : Version 2 of the XML Parser for Java, besides
incorporating
: an
: : : XSLT processor, has been re-architected from version 1.
This
: : has
: : : resulted in a number of changes to the class names
: especially
: : : those that support Namespaces. See v2changes.txt and
: the .diff
: : : difference files in the sample directory.
: : : Oracle XML Team
: : : http://technet.oracle.com
: : : Oracle Technology Network
null -
Does the latest release of the Oracle XML Parser for Java support JDK 1.2.2?
I have an application which makes use of the XML Parser which runs fine with JDK 1.1.7.
But the application crashes with the use of JDK 1.2.2 .
Any insight into this is appreciated.
nullThe Oracle XSQL Servlet makes extensive use of the Oracle XML Parser for Java V2 as well as its XSLT Engine and runs without issue under 1.1.8 and 1.2.2.
-
I download the XML Parser for Java 3.2.1 Release from the IBM site and I have JDK1.3 installed on my Windows 2000 PC. I've placed the files "xerces.jar" and "xalan.jar" in the location specified by the extensions mechanism (i.e "C:\JDK1.3\jre\lib\ext\").
I downloaded an example where java uses XML but I get an error because it fails to import the following class:
import com.ibm.xml.parser.Parser;
Also in another application the same thing happens with this class:
import com.ibm.xml.parser.TXDocument;
If I remove the xerces and xalan JAR files from the directory mentioned above I get move errors so I presume I have the files in the right location. Do I need to place any other files in that DIR other than the xerces and xalan JAR files?
Any help greatly appreciated!Not sure if you solved your problem.
I think Xerces was handed over to the Apache organisation by IBM and the package names were then changed so that com.ibm would have become org.apache or whatever. At a guess nobody got round to changing the examples. -
Parser for Java v2 decimal formatting bug
XML Parser for Java v2 (up to 2.0.2.7) does not seem to format decimal numbers correctly with format-number() function. It can handle floats, but not doubles. When can this bug get fixed?
BTW, is there a bug database for Java XML Parser?
Thanks,
nullThanks for your prompt response, here is one test:
format.xml:
<?xml version="1.0"?>
<numberlist>
<number>1234567.123456789</number>
<number>12345678.123456789</number>
<number>123456789.123456789</number>
</numberlist>
format.xsl:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="number">
<xsl:value-of select="format-number(current(), '#,##0.00000000')"/>
</xsl:template>
</xsl:stylesheet>
The following output was generated from 2.0.2.7:
<?xml version = '1.0' encoding = 'UTF-8'?>
1,234,567.12500000
12,345,678.00000000
123,456,792.00000000
Apache Xalan 0.20 generates the following:
<?xml version="1.0" encoding="UTF-8"?>
1,234,567.12345679
12,345,678.12345679
123,456,789.12345679
This problem also exists in v2 versions before 2.0.2.7.
A month ago, I posted another bug report, but didn't get any reponse. Can someone look into the problem? I suspect XMLElement.setAttribute(name, value) doesn't add attributes of ID type to the internal list of ID's. The posting is at:
http://technet.oracle.com:89/ubb/Forum11/HTML/000994.html
Thanks,
null -
XML Parser for Java version 2.0.2.9
I can no longer find the XML parser for Java (version 2.0.2.9) for Sun Solaris and Oracle version 8.1.7.3. This would be the file xmlparserv2.jar for parser version 2.0.2.9
This file support the latest Oracle Applications work flow version and so is necessary but does not seem to be available. All notes on Metalink point to Techweb.
Thanks for your help. -Erik StromholtThis is covered by patch for bug 2199206. Thanks
-
Upgrading Oracle XML Parser for Java v9.0.4 with Oracle Applications 11i
Guys, I applied ATG.PF.H.RUP4. In postinstall steps it is mentioned,Upgrading Oracle XML Parser for Java v9.0.4 with Oracle Applications 11i(doc-271148.1)
which says after applying patch 4038964 do the following--
AUTOCONFIG ENABLED APPLICATIONS ENVIRONMENT
If the Oracle E-Business Suite configuration files are maintained using the AutoConfig infrastructure, proceed with the following:
1. Run the AutoConfig utility.
2. Go to [JAVA_TOP].
3. Run the unzip -l appsborg2.zip | grep 9.0.4 command. If there is a file named as .xdkjava_version_9.0.4.0.0_production, which indicates that XML Parser for Java v9.0.4 is installed correctly as part of appsborg2.zip. Otherwise, run ADAdmin to regenerate the appsborg2.zip file.
4. Restart the application tier server processes such that the new version of Oracle XML Parser for Java will take effect.
but actually the patch is already applied- 4038964. How do i verify if i need to do these steps or not.
The xmlparserv2-904.zip file is already there in wrapper.classpath. of jserv.properties, forms.properties. So i think i dont need to do these steps.unzip -l appsborg2.zip | grep 9.0.4
0 04-18-03 20:10 .xdkjava_version_9.0.4.0.0_production
do i still need to do that step?No, you do not have to since "XML Parser for Java v9.0.4" is already installed as part of appsborg2.zip -
Can't use UTF-16 encoding with XML Parser for Java v2.
This is my XML Document:
<?xml version="1.0" encoding="UTF-16" ?>
<Content>
<Title>Documento de Prueba de gestin de contenidos.</Title>
<Creator>Roberto P rez Lita</Creator>
</Content>
This is the way in which i parse de document:
DOMParser parser=new DOMParser();
parser.setPreserveWhitespace(true);
parser.setErrorStream(System.err);
parser.setValidationMode(false);
parser.showWarnings(true);
parser.parse(
new FileInputStream(new File("PruebaA3Ingles.xml")));
I've got this error:
XML-0231 : (Error) Encoding 'UTF-16' is not currently supported.
I am using the XML Parser for Java v2_0_2_5 and I am a little
confused because the documentation says that the UTF-16 encoding
is supported in this version of the Parser.
Does anybody know how can I parse documents containing spanish
accents?
Thanks in advance.
Roberto P rez.
nullOracle just uploaded a new release of V2 Parser. It should
support UTF-16.
Yet, other utilities still have some problems with UTF-16
encoding. Seems we just
have to wait this one out.
BTW, I'm trying to use Japanese. We, also, have some problems
with JServer.
Roberto P rez (guest) wrote:
: This is my XML Document:
: <?xml version="1.0" encoding="UTF-16" ?>
: <Content>
: <Title>Documento de Prueba de gestin de contenidos.</Title>
: <Creator>Roberto P rez Lita</Creator>
: </Content>
: This is the way in which i parse de document:
: DOMParser parser=new DOMParser();
: parser.setPreserveWhitespace(true);
: parser.setErrorStream(System.err);
: parser.setValidationMode(false);
: parser.showWarnings(true);
: parser.parse(
: new FileInputStream(new File("PruebaA3Ingles.xml")));
: I've got this error:
: XML-0231 : (Error) Encoding 'UTF-16' is not currently supported.
: I am using the XML Parser for Java v2_0_2_5 and I am a little
: confused because the documentation says that the UTF-16
encoding
: is supported in this version of the Parser.
: Does anybody know how can I parse documents containing spanish
: accents?
: Thanks in advance.
: Roberto P rez.
null -
Installing XML Parser for Java v2
I downloaded Oracle XML Parser for Java v2 and looked in the doc directory of the unzipped files but couldn't find any doc about installation. Can anyone point me in the right the direction or tell me how to install and use it to convert XML files stored in the files system to HTML output using XSL stylesheet. Thanks
There is no installation involved beyond including the xmlparserv2.jar in your CLASSPATH. Take a look in the sample directory where we have included sample code and instructions on their use.
Addiaitonal HTML conversion samples are included with the XSQL Servlet download.
Oracle XML Team
null -
XML PARSER for JAVA V9.0.4 version check
Hi,
One of post patch activity for RUP7 in 11i(11.5.10.2) is UPGRADE ORACLE XML Parser for java V9.0.4 version (required). When I checked few things it's confirm that I'm already in java V9.0.4 version?
Is there any script/doc where I can look and check "XML PARSER for JAVA V9.0.4 version in Oracle E-business Suite 11.5.10.2?
thanksHi,
Please see these docs.
Upgrading Oracle XML Parser v9.0.4 with Oracle Applications 11i [ID 271148.1]
How To Setup Oracle XML parser with PL/SQL with Oracle Applications 11i [ID 160474.1]
Oracle XML Gateway Troubleshooting Guide [ID 167474.1]
XML Gateway Setup Testing and Diagnostics [ID 337428.1]
Thanks,
Hussein
Maybe you are looking for
-
Multiple Vendor Line item in FB60
Hi Friends, It may be simple question but I stucked with it. I want to split a Vendor Invoice document in FB60(Enjoy Transactions.) by using special Indicator for Retention amount. You will be clear from below example :--- Inventory Rawmate
-
I need to install windows on my new Macbook pro for running my flight simulator software
Hi! I'm new to the Mac world and I need to install windows on my new Macbook pro for running my flight simulator software which only runs on windows. I would like to purchase and download the windows 8.1 rather than buying the CD. When i go to the mi
-
When I close my iTunes.exe process, my computer bluescreens
So lately when i go to open my Itunes from my taskbar, the image is highlighted but shortly fades away and nothing opens. I decided to end the process in the task manager (iTunes.exe) but soon after my computer bluescreens. I have tried this a couple
-
How to copy DVDs within Mac OS X 10.4 Tiger
Is there a way to copy a DVD made from iDVD or DVD Studio Pro in mac os without a program such as Toast, using just mac os? Thanks.
-
Alert: Magican and Request for Help
I made the mistake of installing some new software, supposedly a cleaning utility called Magican, which I think may be some kind of malware. Immediately after running it, I began to have problems launching some applications. I tried to remove it and