Java LEX Parsers .
Does anyone knows anything about LEX parsers.
Actually i want to know if there is any BINARY regular expressions exist in LUX or not?
like for other types available are:
DENTIFIER [A-Za-z_$][A-Za-z_$0-9]*
DIGIT [0-9]
HEXDIGIT [A-Fa-f0-9]
OCTDIGIT [0-7]
DECNUMBER [1-9]{DIGIT}*
HEXNUMBER 0[Xx]{HEXDIGIT}+
OCTNUMBER 0{OCTDIGIT}*
DECLONG {DECNUMBER}[Ll]
HEXLONG {HEXNUMBER}[Ll]
OCTLONG {OCTNUMBER}[Ll]
EXPONENT [Ee][+-]?{DIGIT}+
Have a look at java.util.regex package in the API docs.
Similar Messages
-
Java XML parsers for Sun J2ME, Sun KVM
Here is a list of "small" XML parsers.
Some are specifically for the J2ME platform / Sun KVM:
kXML
http://kxml.enhydra.org/
NanoXML
http://nanoxml.sourceforge.net/
TinyXML
http://www.gibaradunn.srac.org/tiny/index.shtml
MinML
http://www.wilson.co.uk/xml/minml.htm
XMLtp
http://sourceforge.net/projects/jxmltp/
Al Sutton XML parser
http://sourceforge.net/projects/asxmlp/
Also:
JSR 118 is a specification for the "Mobile Information Device
Next Generation"
http://www.jcp.org/jsr/detail/118.jsp
The JSR 118 group is considering adding a "small, efficient XML parser to enable platform-independent data exchange" to MIDP.Fastparser is a 25Ko parser : http://www.japisoft.com/fastparser
Best regards,
A.Brillant -
XSD size and Java XML Parsers (specifically SAX)
Does the size of XSD matter in terms of performace runtime. I would like to create an XSD as one contract that houses all non-mandatory elements so the resulting xml out of this will use similar structure but wont use all of the XSD elements.
Is there a problem with such an XSD which will be 1000 or more elements as far as Java parsing is concerned
Pl. let me knwo thanksI do a lot of work with an international standard -- S1000D -- for documentation and technical manuals. It has 58 schema files (10 that are main files that are referenced by an XML file, and the other 48 get imbedded as needed). It does not slow down the parsing of files by any noticable amount.
Dave Patterson -
Is java.xml.parsers.DocumentBuilder Thread Safe?
Does anyone know if the DocumentBuilder is thread safe? Meaning,
can I call the parse(...) methods from several threads simultanously, without getting errors?
I would be happy if anyone can also point me to the documentation that says DocumentBuilder is or isn't thread safe.My Code Like Such:
public class DigestUtil
private static MessageDigest md_md5 = null;
static
try{
md_md5 = MessageDigest.getInstance("MD5");
}catch(Exception ex)
public static byte[] DigestMD5(byte[] b)
return b==null ? null : md_md5.digest(b);
I Don't Wish to Every Digest, Every Create MessageDigest Instance. -
Patterns for complex parsers, scanner, compilers
Can anyone suggest some good pattern sequence or some resurces on the net that can help in designing complex language parsers, scanners and things like that?
I developed a simple sql parser in java that starting from a query string extract a kind of query object model of the query, with param objects, clauses, etc., it works actually but i ended up with few complex methods that have a really high cyclomatic complexity, , very bad :)), so it shurely could be improved using the right patterns i guess.
Bye, thx
BennyLook at JavaCC:
https://javacc.dev.java.net/
It's a great Java lex/yacc tool that's been around for a very long time. (I first used it in 1999). It's based on the GOF Interpreter. If you can express your problem in a grammar, it might be a good solution. - MOD -
I'm doing a project of converting XML from one format to another. The conversion is very complex. It contains hundreds of complex conversion rules and many calculations.
Should I do it with XSLT or with Java? (Using the Java XML parsers)
What are the advantages and disadvantages of each approach?
Thanks,
Danielusing xslt allow to entirely transform any xml into nearly something text based else.
Considering that Java has not an independent way of doing transformation, it relies on something already builded (saxon, xerces, ecc...)...so in the end you are using java as a "middleware" (can I say that ?).
XSLT is a standard not a program for transforming, an xsl transformer has to stick to that standard...and a transformer can be built with many technologies...java .net ecc...
You should use java if you want to do something more with that file:
- who's doing the transform ? A final user ? Are you on an intranet with a given browser such as iexplorer ? If yes you could consider using facilities provided by the browser.
- can everybody access and transform that file ? If not a java app can keep better control on that.
- what are you doing with the transformed data ?
- ecc---
There are more questions like that you have to answer...I would say...if you mention java it means you can use java in your project. So, use xslt with java, because if your project evolves in the future, you are ready to make it evolves... -
How do we use the Java Section (Message mapping>Design>Edit Java Sections) in IR.
Hi,
Edit Java function is to specify global variables and to mentioned about additional Java sections for all Java functions.
The mapping is internally based on Java SAX parsers so runtime first it will include the Java packages specified under Imports. It will be used if any special package need to be import else the standard Java.lang or Maths packages have default imported no need to mentione about it.
You can enter the same packages entered for a user-defined function. Then the mapping runtime declares the variables entered as global variables and executes the sections in the following order:
1. Initialization section
2. Message mapping
3. Cleanup section
Thanks
Swarup
Edited by: Swarup Sawant on Mar 10, 2008 7:25 AM -
I'm trying to add my Java lexer to Oracle 10g as a USER_LEXER. I've already checked Roger's example and many other websites but I'm still stuck with details.
Does anybody know what is the right mapping of the parameter list of the indexing procedure to Java? Especially the output CLOB is the question.
I've tried many variants, e.g.
CREATE OR REPLACE PROCEDURE my_index_proc(inDoc CLOB,outXml CLOB,empty BOOLEAN) AS
LANGUAGE JAVA NAME 'MyLexer.index(oracle.sql.CLOB, oracle.sql.CLOB, boolean)';
or
CREATE OR REPLACE PROCEDURE my_index_proc(inDoc CLOB,outXml CLOB,empty BOOLEAN) AS
LANGUAGE JAVA NAME 'MyLexer.index(oracle.sql.CLOB, oracle.sql.CLOB[], boolean)';
but none of them work as I would expect.
Another strange thing: when I run my lexer (e.g. create an index with it), it seems so that the input CLOB is just the string "Mr" every time and nothing else (regardless of the content of the doc). What can be the reason for that?
Cheers,
BorbalaMeanwhile I've learned the reason of the CLOB content phaenomenon (why the doc contents are "Mr").
The system calls the indexer method for the stop words before calling it for the documents themselves. And the first stop word is "Mr". So it's not a problem of any kind. -
XML performance issue in Oracle 8i
I have implemeted the code as per the link http://www.oracle-base.com/articles/8i/parse-xml-documents-8i.php to convert & Load an XML Document to multiple tables in Oracle database. As the number of nodes increase in the xml file, the processing time of XML file is increasing exponentially.(For Example:- if there are more than 500 Employee-Dept details in an XML file, parsing of XML file is taking about 5 hours ) Could anyone let me know what changes can be done inorder to reduce the parsing time.
Tim (Hall) starts with "First, download and install the latest copy of the XDK for PL/SQL.", so yes, you could try again on the XDK forum. As long as you don't upgrade, we can't really help.
Thinking out of the box, a lot has improved since the "birth" of 8i, so alternatively you could load faster Java solutions (parsers etc of non oracle flavor, that is the very old XDK) into Oracle's JVM kernel and access those via you own PL/SQL wrappers / packages.
Edited by: Marco Gralike on Aug 22, 2012 7:33 PM -
XML Parse issues when using Network Data Model LOD with Springframework 3
Hello,
I am having issues with using using NDM in conjuction with Spring 3. The problem is that there is a dependency on the ConfigManager class in that it has to use Oracle's xml parser from xmlparserv2.jar, and this parser seems to have a history of problems with parsing Spring schemas.
My setup is as follows:
Spring Version: 3.0.1
Oracle: 11GR2 and corresponding spatial libraries
Note that when using the xerces parser, there is no issue here. It only while using Oracle's specific parser which appears to be hard-coded into the ConfigManager. Spring fortunately offers a workaround, where I can force it to use a specific parser when loading the spring configuration as follows:
-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl But this is an extra deployment task we'd rather not have. Note that this issue has been brought up before in relation to OC4J. See the following link:
How to change the defaut xmlparser on OC4J Standalone 10.1.3.4 for Spring 3
My question is, is there any other way to configure LOD where it won't have the dependency on the oracle parser?
Also, fyi, here is the exception that is occurring as well as the header for my spring file.
org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException:
Line 11 in XML document from URL [file:/C:/projects/lrs_network_domain/service/target/classes/META-INF/spring.xml] is invalid;
nested exception is oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
[snip]
... 31 more
Caused by: oracle.xml.parser.schema.XSDException: Duplicated definition for: 'identifiedType'
at oracle.xml.parser.v2.XMLError.flushErrorHandler(XMLError.java:425)
at oracle.xml.parser.v2.XMLError.flushErrors1(XMLError.java:287)
at oracle.xml.parser.v2.NonValidatingParser.parseDocument(NonValidatingParser.java:331)
at oracle.xml.parser.v2.XMLParser.parse(XMLParser.java:222)
at oracle.xml.jaxp.JXDocumentBuilder.parse(JXDocumentBuilder.java:155)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)Here is my the header for my spring configuration file:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">Thanks, TomI ran into this exact issue while trying to get hibernate and spring working with an oracle XMLType column, and found a better solution than to use JVM arguments as you mentioned.
Why is it happening?
The xmlparserv2.jar uses the JAR Services API (Service Provider Mechanism) to change the default javax.xml classes used for the SAXParserFactory, DocumentBuilderFactory and TransformerFactory.
How did it happen?
The javax.xml.parsers.FactoryFinder looks for custom implementations by checking for, in this order, environment variables, %JAVA_HOME%/lib/jaxp.properties, then for config files under META-INF/services on the classpath, before using the default implementations included with the JDK (com.sun.org.*).
Inside xmlparserv2.jar exists a META-INF/services directory, which the javax.xml.parsers.FactoryFinder class picks up and uses:
META-INF/services/javax.xml.parsers.DocumentBuilderFactory (which defines oracle.xml.jaxp.JXDocumentBuilderFactory as the default)
META-INF/services/javax.xml.parsers.SAXParserFactory (which defines oracle.xml.jaxp.JXSAXParserFactory as the default)
META-INF/services/javax.xml.transform.TransformerFactory (which defines oracle.xml.jaxp.JXSAXTransformerFactory as the default)
Solution?
Switch all 3 back, otherwise you'll see weird errors. javax.xml.parsers.* fix the visible errors, while the javax.xml.transform.* fixes more subtle XML parsing (in my case, with apache commons configuration reading/writing).
QUICK SOLUTION to solve the application server startup errors:
JVM Arguments (not great)
To override the changes made by xmlparserv2.jar, add the following JVM properties to your application server startup arguments. The java.xml.parsers.FactoryFinder logic will check environment variables first.
-Djavax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl -Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl -Djavax.xml.transform.TransformerFactory=com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl
However, if you run test cases using @RunWith(SpringJUnit4ClassRunner.class) or similar, you will still experience the error.
BETTER SOLUTION to the application server startup errors AND test case errors:
Option 1: Use JVM arguments for the app server and @BeforeClass statements for your test cases.
System.setProperty("javax.xml.parsers.DocumentBuilderFactory","com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
System.setProperty("javax.xml.parsers.SAXParserFactory","com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl");
System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
If you have a lot of test cases, this becomes painful.
Option 2: Create your own Service Provider definition files in the compile/runtime classpath for your project, which will override those included in xmlparserv2.jar.
In a maven spring project, override the xmlparserv2.jar settings by creating the following files in the %PROJECT_HOME%/src/main/resources directory:
%PROJECT_HOME%/src/main/resources/META-INF/services/javax.xml.parsers.DocumentBuilderFactory (which defines com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl as the default)
%PROJECT_HOME%/src/main/resources/META-INF/services/javax.xml.parsers.SAXParserFactory (which defines com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl as the default)
%PROJECT_HOME%/src/main/resources/META-INF/services/javax.xml.transform.TransformerFactory (which defines com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl as the default)
These files are referenced by both the application server (no JVM arguments required), and solves any unit test issues without requiring any code changes.
This is a snippet of my longer solution for how to get hibernate and spring to work with an oracle XMLType column, found on stackoverflow. -
Hi Techies,
I m making a xml document and that is validated on xml schema. But it is giving error that document is not valid because it is not deg\fining DOCTYPE element. Is it necessary to define itIt is not nesessary, but you have probably made your parser validating. In Java validating parsers use DTD to validate, and while schema validation is possibly those parsers are non-validating.
-
ive been having a terrible time trying to find out how to parse just a short XML string. for example:
<action name="setColor">black</setProperty>
how should I go about parsing it and extracting attributes/textnodes?
none of the xml strings will be more than 1 node deep, and keep in mind that im n00b and have no experience with java XML parsers. thankeewhoops, old xml should read like this:
<action name="setColor">black</action> -
Hello,
I was wondering if anybody had any experience in regards to the relative performance (i.e., speed) of the different Java XML parsers out there. Specifically,
javax.xml.parsers.DocumentBuilder.parse() vs. any others.
My goal is to reduce the amount of time needed to parse ~1000 XML files (avg size 3kb) and I have done some tests that lead me to conclude that the rate-limiting step is not the file i/o (surprisingly).
Is there any particular XML parser that people favor?
Thanks,
cklI have created a parser with interesting performance result with
files < 100 Ko at http://www.japisoft.com/fastparser
Regards,
A.Brillant -
Hi!
I have a question: I would like to use Oracle's XSQL servlet. I have a .xsql file
which calls a function and returns a data in XML format. Now how can I use this
in weblogic using webservices?
Anybody has an idea?
Thanks in advance
..MadhuriCurrently, WebLogic Web Services only use Stateless Session EJBs (for RPC-style)
and JMS destinations (for Message-style). You can, of course, deploy other Web
Service Platforms (i.e. Apache SOAP, GLUE, WASP, etc.) on WLS 6.1 and use them
;-) They usually support using POJOs (Plain Old Java Objects) as Web service implementations.
Is there some reason why you just aren't using the XSQL stuff by itself? It seems
to be designed specifically for making SQL queries over HTTP, using XML ;-) Why
do you need to create a Web service to "front-end" this capability? Seems like
extra overhead (i.e. SOAP message processing, etc.) with no real "value-added",
if you know what I mean ;-) Is it because you want (or need) to introduce a "layer"
or facade pattern for XSQL, or something?
Regards,
Mike Wooten
"Madhuri" <[email protected]> wrote:
>
Hi Mike!
Thanks for the help. Is there any other way, I mean without using EJBs
can I achieve
the task?
...Madhuri
"Michael Wooten" <[email protected]> wrote:
Hi Madhuri,
Unfortunately, it sounds like you will need more help than I can offer
at this
time. From your original post, I was under the impression that you knew
about
EJBs, Java XML parsers/XSLT processors, etc. I scoped out XSQL a bit
more, and
it looks like fairly powerful technology, but it requires knowledgeof
XML/XSLT.
Personally, I think you might need some "training" help to create aXSQLService
with a WebLogic Web Service ;-) If you don't have time for that, perhaps
you can
search the Web for example code, and start from there.
Regards,
Mike Wooten
"Madhuri" <[email protected]> wrote:
Hi Mike !
Do you have any sample code for the EJB where the method that accepts
an org.w3c.dom.Element
(or org.w3c.dom.Document) as a parameter, and returned the same, asI
am new for
the EJB or direct me the link where I can get info.. I really appresite
your help.
Thanks
..Madhuri
"Michael Wooten" <[email protected]> wrote:
Yeah, that's what I thought ;-)
If you want the party that submitted to wait while the XSQL file isbeing
processed,
you'll want to build a RPC-style WebLogic Web Service, using the Literal
XML encoding
style. For this, you would have the Stateless Session EJB that actsas
the entry-point
into your Web service "implementation", have a method that accepts
an
org.w3c.dom.Element
(or org.w3c.dom.Document) as a parameter, and returned the same. The
remote interface
for this SS would look something like this:
public interface XSQLService extends javax.ejb.EJBObject
public org.w3c.dom.Element process(org.w3c.dom.Element xsqlParameters)
throws
java.rmi.RemoteException, org.xml.sax.SAXException;
From the information posted on Oracle's OTN site, the .xsql file(s)will
live
on the "server side", so all you need the Web service client to send
is the parameters
for the .xsql, right? That's why I called the input argument "xsqlParameters"
in the method signature above ;-) Okay, so now we need a way for the
client to
tell us which .xsql file to use, right? If the client knows this,
it's
probably
simpler if they put that in the parameter file too! So using the flighFinder
example
on OTN, that leaves us with a parameter file that looks kind of like
this:
<query uri="fly.xsql" stylesheet="none">
<parameters>
<FROM>LAX</FROM>
<TO>SFO</TO>
</parameters>
</query>
The implementation for the process(org.w3c.dom.Element xsqlQuery)method,
is where
you want to create the java.net.URL and java.net.URLConnection toconnect
to the
actual XSQL Servlet, I think. You could them use the getOutputStream()
method
on URLConnection, to get the XML returned by the XSQL Servlet, andmake
it the
return value. Knowing Oracle, they have defined a MIME-type extension
for xsql,
which is how they can "automagically" route http://localhost:7070/fly.xsql
to
the XSQL Servlet. Anyway, I haven't worked with XSQL Servlet before,
but I would
hope it is just a J2EE Web Application (.war file) that can be deployed
into WLS.
If so, it should be relatively simple to do what you want to do.
Regards,
Mike Wooten
"Madhuri" <[email protected]> wrote:
Hi Mike, Thanks for your prompt reply. I would like to send the XSQL
file to a
Web Service, and have it send it to the Oracle XSQL Servlet for processing.
As
XSQL Servlet processes SQL queries and outputs the result set as
XML,and
servlet
takes an XML file containing embedded SQL queries (XSQL file), asits
input. It
returns the data in XML format and that's what exactly I would liketo
do.
Thanks ..Madhuri
"Michael Wooten" <[email protected]> wrote:
Hi Madhuri,
What kind of WebLogic Web Service do you want to use? Document-oriented
(i.e.
where you pass in an XML document/well-formed fragment), or RPC-style
(i.e. where
you pass in function arguments)? What does the client pass to the
Web
Service?
What, if anything, does it get back?
From what I know, the Oracle XSQL Servlet processes SQL queries
and
outputs
the
result set as XML. This servlet takes an XML file containing embedded
SQL queries
(XSQL file), as its input. Do you want to send the XSQL file to
a
Web
Service,
and have it send it to the Oracle XSQL Servlet for processing? Doyou
want the
Web Service to create the XSQL file, from arguments passed in theSOAP
Body element?
Sorry to ask so many questions, but the answers will help me answeryour
"original"
question ;-)
Regards,
Mike Wooten
"Madhuri" <[email protected]> wrote:
Hi!
I have a question: I would like to use Oracle's XSQL servlet. I
have
a .xsql file
which calls a function and returns a data in XML format. Now howcan
I use this
in weblogic using webservices?
Anybody has an idea?
Thanks in advance
...Madhuri -
Howto force Oracle XML parser not to expand entity references?
Hi,
Is it possible to force Oracle XML parser (Java) not to expand entity references, so that they appear in DOM tree as separated nodes after parsing XML?
Example:
for following XML
<tag>abcäxyz</tag>
I get:
Element: "tag"
|-Text: "abcdxyz"
but I would like to get:
Element: "tag"
|-Text: "abc"
|
|-EntityReference: "auml"
|
|-Text: "xyz"
I've already tried to use JAXP api (setExpandEntityReferences method in java.xml.parsers.DocumentBuilderFactory), but it doesn't seem to work.
I'm using parser from XDK Java v9.2.0.2.0 Production.
Thx,
JamesThis is requested code sample:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setExpandEntityReferences(false);
System.out.println("isExpandEntityReferences = "+dbf.isExpandEntityReferences());
DocumentBuilder db = dbf.newDocumentBuilder();
Document d = db.parse("file://c:/test.xml");
Element e = d.getDocumentElement();
System.out.println("documentElement"+ e.getTagName() + " nodeType=" +e.getNodeType());
System.out.println("ChildNodes:");
NodeList nodeList = e.getChildNodes();
for(int i=0; i<nodeList.getLength();i++) {
System.out.println(i+" value=\""+nodeList.item(i).getNodeValue()+"\" nodeType="+nodeList.item(i).getNodeType());
Content of test.xml:
<!DOCTYPE test SYSTEM "test.dtd">
<test>abcäxyz</test>
Content of test.dtd:
<!ELEMENT test (#PCDATA)>
<!ENTITY auml "ä">
When you run it you will get the following output:
isExpandEntityReferences = true
documentElementtest nodeType=1
ChildNodes:
0 value="abcdxyz" nodeType=3
which means that EntityReference has been expanded.
As you can see in the output the isExpandEntityReferences method returns "true", even though I set it to false in code!
Does it mean that Oracle parser simple doesn't support this feature???
Thx,
James
Maybe you are looking for
-
Plug in Mini Diplayport to HDMI, Lose Audio Output
For the first time today, I plugged in my mid 2009 MBP5,3 into my TV using an HDMI to mini displayport cable. I got video, but no sound. Ever since then, I have had no sound of any kind come out of the computer's speakers. When I look in System Prefe
-
Publish a file to a different directory.
I've seen other questions similar to mine on the forums but haven't found an answer. My site has a newsletter archive that links to all of our past newslettters. The newsletters are just html files saved from emails we send out. To keep things orga
-
Why is the Design View appearing distorted?
I have been designing an event page template in HTML and CSS to be used by my co-worker who handles all of our events and doesn't know how to write in HTML. When I enter the HTML into the Event Content (HTML) entry box, everything works fine. The pag
-
SNR License Issue. How Can I Disable SNR for all Users?
Hi, I Have an issue with SNR on CUCM 10.5 and with assignement of license type I have a cluster with 400 users. 200 users use ip phone 3905 and should be use an Essential License. When system check for assignement of license type , itassign a Basic L
-
How can I tell what email address I used
Trying to connect my iPad to hpeprint.I am new at this so I made a account.it said I already have a account but when I ask for my password to be sent to my email it says my account can't be found.what should I do.