Parse document without validating

Hi all,
I'm writing a program which will be run in a stand alone machine (i.e. no network connection). When I parse my document which contain a "DOCTYPE", it will have an exception. Also, I don't want to store the DTD file in my local machine. How can I parse a document without validating it in a SAXParser? Thx for all.
Here is my parser code:
SAXParserFactory factory = SAXParserFactory.newInstance();
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.setContentHandler(new SaxParser());
reader.parse(xml_file);
In the XML document:
<!DOCTYPE package PUBLIC "+//ISBN....." "http://abc.org/dtd.....">
The exception is:
java.net.UnknownHostException: abc.org

how about this code?
SAXParserFactory factory = SAXParserFactory.newInstance();
//disable validation
factory.setValidating(false);
XMLReader reader = factory.newSAXParser().getXMLReader();
reader.setContentHandler(new SaxParser());
reader.parse(xml_file);

Similar Messages

  • Parse file without xml specification or document element

    I have a large (600mb) log file that is in xml format but it does not have an xml specification and has no document element.
    file looks like this:
    <message>...</message>
    <message>...</message>
    <!-- ... many many many more <message> elements -->
    <message>...</message>
    <message>...</message>
    I have written a class that overrides the SAX DefaultHandler but now want to be able to parse the document without having to add the xml spec and document element manually.
    I've thought about writing a subclass of FileReader that adds the xml specification and document element before reading physical file but would also need to add closing document element at end of file.
    Is there a simpler way?

    Hi,
    There is another way around the problem of adding a missing root node. This involves adding an extra DTD file and a xml file, like this one:
    <?xml version='1.0' encoding='UTF-8' standalone="no"?>
    <!DOCTYPE messageSet SYSTEM "logfile.dtd"
    [<!ENTITY data SYSTEM "logfile.xml">]
    >
    <messageSet>
    &data;
    </messageSet>
    This file "includes" the logfie.xml, as an external entity, with your messages as child nodes of element messageSet.
    In your program you refer to this xml file when parsing the messages.

  • Xml transformation without validation

    Hi,
    How can I carry out an xsl transformation in java without validating the xml document??
    regards
    anand

    Well I've a DomSource and I want to transform it using a templates defined in an XSL file.
    This is how I'm doing it
    Source source = new DOMSource(document);
    TransformerFactory.newInstance().newTransformer().transform(source, new StreamResult("temp.xml"));
    The stack trace I'm getting is:
    ERROR: 'The entity "bull" was referenced, but not declared.'
    ERROR: 'com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.'
    Exception in thread "main" javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:654)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at temp.Temp.main(Temp.java:115)
    Caused by: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:496)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
         ... 2 more
    Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
         ... 3 more
    javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:496)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at temp.Temp.main(Temp.java:115)
    Caused by: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
         ... 3 more
    com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at temp.Temp.main(Temp.java:115)
    org.xml.sax.SAXParseException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
         at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
         at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
         at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
         at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1332)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1756)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:387)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at temp.Temp.main(Temp.java:115)
    com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:393)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at temp.Temp.main(Temp.java:115)
    org.xml.sax.SAXParseException: The entity "bull" was referenced, but not declared.
         at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
         at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:215)
         at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:386)
         at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:316)
         at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1438)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(XMLDocumentFragmentScannerImpl.java:1332)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1756)
         at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:368)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:834)
         at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
         at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:148)
         at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1242)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:387)
         at com.sun.org.apache.xalan.internal.xsltc.dom.XSLTCDTMManager.getDTM(XSLTCDTMManager.java:228)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.getDOM(TransformerImpl.java:474)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:644)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:281)
         at temp.Temp.main(Temp.java:115)
    I don't want to resolve any entity references.
    Message was edited by:
    anand_nalya

  • Clearing document without line items

    Hello,
    While doing automatic/manual clearing, clearing doc gets posted with zero line items. We have requirement that documents without any line item can not appear in the legal books.
    Apart from validation/substitution, is there any way to avoid this ?

    Hello Mauri,
    Thanks for your answer.
    Problem is not how clearing rules/lines work but is there any solution in SAP to stop a clearing document being created without line items.
    For eg - while doing clearing,  FX gain/loss line item arises with zero amount in local currency. I know this is standard behaviour & also correct one, but, the requirement is that such zero lines can not appear in the legal books.
    Do you have any solution ?
    Thanks in Advance.
    Regards,
    Amol

  • Transform XML without validating

    Hi, I use Xalan to transform an XML file.
    I use Tranformer.class, I just want to tranform the XML without validating the file.
    In the parser class, you can use setValidate to avoid or not the validating action.
    Do you know how to do the same with Transformer.class
    Thanks C�dric

    This one piqued my interest, and as no one had responded
    yet I thought I'd poke around and see what's up.
    I looked at the Transfermer class, and the javadoc pointed
    me to the OutputKeys class, the only thing that looked
    remotely interesting was the "STANDALONE" feature. I wonder
    if you can set it to "true" and avoid the validation (as I
    think Standalone implies, no DTD to validate against?)
    Eric

  • Oracle XML parser and schema validation

    Hi Forum,
    I have problem parsing XML with validation against XML schema. I define location of schema (URL) in xml file and Oracle parser could not find the schema (xml file is correct - checked in other programs). When I point to xml schema directly from Java (using parser.setXMLSchema) before calling parser.parse, it works just fine. Where is the problem? Does oracle parser works correctly with XML Schema?
    TIA,
    Alex

    SAXParser saxParser=new SAXParser();
    saxParser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    Specify a Schema to validate a XML document with, for the SAXParser.
    saxParser.setXMLSchema(SchemaUrl);
    DefaultHandler handler=new DefaultHandler();
    saxParser.setErrorHandler(handler);
    Parse the XML document to validate with the XML schema.
    saxParser.parse(XmlDocumentUrl);

  • Memory Leakage while parsing and schema validation

    It seems there is some kind of memory leakage. I was using xdk 9.2.0.2.0. Later i found that from this forum which contain a Topic on this and they (oracle ) claim they have memory leakage. And they have fixes this bugs in 9.2.0.6.0 xdk. When i used truss command, for each call to parser and schame validation, it was opening file descriptor for lpxus and lsxus file. And this connections were not close. And keep on openning it with each call to parser. I was able to diagonise this using truss command on on solaris. After making many calls, i was error message could not open file Result.xsd (0202). I am using one instance of Parser and Schema. And i am doing clean up for parser after each parse.
    Later i downloaded, 9.2.0.6.0,
    Above problem for the parser was solvedm but still the problem continued for schema validation. And even i tried with latest beta release 10.
    And this has caused great troubles to us. Please can u look whether there is come sort of leakage. Please advice if u have any solution.
    Code---
    This below code is called multiple times
    char* APIParser::execute(const char* xmlInput) {
              char* parseResult = parseDocument(xmlInput);
              //if(strcmp(parseResult,(const char*)"")==0) {
    if(parseResult == NULL) {
                   parseResult = getResult();
    parser.xmlclean();
         return parseResult;
              } else {
                   return parseResult;
    Parser and schema are intialised in Construtor and terminated in Destructor.

    Hi, here is the complete test case
    #include<iostream>
    #ifndef ORAXML_CPP_ORACLE
    # include <oraxml.hpp>
    #endif
    using namespace std;
    #define FAIL { cout << "Failed!\n"; return ; }
    void mytest(int count)
         uword ecode;
         XMLParser parser;
         Document *doc;
         Element root, elem;
         if (ecode = parser.xmlinit())
              cout << "Failed to initialze XML parser, error " << ecode << "\n";
              return ;
         cout << "\nCreating new document...\n";
         if (!(doc = parser.createDocument((oratext *) 0, (oratext *) 0,(DocumentType *) 0)))
         FAIL
         if (!(elem = doc->createElement((oratext *) "ROOT")))
                   FAIL
         string test="Elem";
         for(int i=0;i<count;i++)
              //test="Elem"+string(ltoa(i));
              if (!(elem = doc->createElement((oratext *) "element")))
                   FAIL
              if (!doc->appendChild(elem))
                   FAIL
         //doc ->print();
         //parser.xmlclean();
         parser.xmlterm();
    int main(int argc,char* argv[])
         int count=atol(argv[1]);
         mytest(count);
         char c;
         cout<<"check memory usage n press any key"<<endl;
         cin>>c;
         return 0;
    -------------------------------------------cut here-----
    Now, i cant use the xdk 10g because i work on a hpux machine. I have tried the above program with a count of 1000000. the memory usage at the end was around 2 gigabytes.
    Could someone please please help me? :(
    Thank you.

  • Restricting for creating the Billing Document without PGI in STO Process

    We want to restrict creating the Billing Document  without PGI in STO Process
    Delivery Type:NL
    Item cataogory:NLN
    Billing Type: JEX Profroma Invoice
    I have check in VTFL
    At Header Level, Routine - 003.  for normal sales process LF-F2
    At Item Level , Routine  - 004
    in VTFL-- NL-JEX
    At Header Level, Routine - 009. 
    At Item Level , Routine  - 010. here when i changed to 003 and 004 for NL and JEX
    i am getting error after PGI when i am doing vf01 error is coming " document is not relevant for Billing"

    Hi
    Kindly do the belwo
    1. goto the t code VOV7 item category determination and select the item category and put  the billing relevance as "A"
    2. once the step 1 is completed then it will show the billing relevant status AS "A"in the delivery documnt at the item level
    The above configuration  will be applicable in the new documents only
    Regards
    Damu

  • How do I add page numbers to my document without the page numbers automatically changing. I do not want the page numbers the software automatically places into my document.

    How do I add page numbers to my document without the page numbers automatically changing? The title page is blank, I can type in 1 on the 1st typed page, but the #1 automatically goes into the next page and will not change.

    Click at bottom of the first page:
    Menu > Insert > Section break
    Click somewhere in the 2nd page (not the header/footer)
    Inspector > Layout > Section > Page Numbers > Start at 1 > Configuration > uncheck use previous headers and footers
    Click into the header or footer of the second page:
    Menu > Insert > Auto Page Numbers…
    If there is anything in the header or footer on the first page that you don't want just select it and delete it.
    If you really wanted to manual place page numbers on each page you will have to use a section break between each and every page. I can't imagine that would be useful.
    Peter

  • How can I paste a part of a sheet from Numbers in Pages as text, without the formulas.The reason I need this (and was used to in Office) so that I have the freedom to delete something in one cell (in pages document) without causing changes.

    How can I paste a part of a sheet that I copied in Numers in a pages document without the formulas, simply as text. Used this a lot in Office. When I make some changes in the pages document. f.i. deleting a cell, I don't want to change other cells. Also when I copy a part of a sheet from Numbers and one of the cells that is part of the formula is not also copied, when I paste in Pages it shows as an error.
    Hope that You can me help with this.

    Leon,
    There are two solutions to the first question, narrowing to one solution when you have a broken link causing an error.
    Here's the "works always" solution.
    Copy (Command-C) the table or range in Numbers
    Click off the table on the blank canvas of the sheet.
    Edit > Paste Values
    Command-C
    Switch to Pages
    Command-V
    Regards,
    Jerry

  • Using Firefox, I used to be able to open a document on a website and look at it without downloading.  Now, I must download a document in order to view it.  How can I change settings so that I can open documents without saving them?

    Using Firefox, I used to be able to open a document on a website, such as a bank statement, and view it without downloading.  Now, I must download and save a document before I can view it.  How can I change settings so that I can open documents without saving them first?

    Do you know what kind of docs they are? Did you upgrade/Update Firefox lately?
    https://addons.mozilla.org/en-US/firefox/addon/pdf-download/
    http://kb2.adobe.com/cps/333/333563.html
    https://addons.mozilla.org/en-US/firefox/addon/open-it-online/

  • Schema of a new Object Type: message pass the BIU without validation

    Hi,
    i've defined a new Object Type for send messages to Web Service. I've created the schema files and i've uploaded there in repository with the "Import" function of GUI. After, i've defined the XML file for the "Execute" function of the B1i GUI.
    After the load of files, in the repository the files are in correct position.
    In my BIU the definition of sender and receiver system type is correct, and also the definition of SenderMainObjectTypeID and ReceiverObjectTypeID. The message from B1 pass through the IPO chain without problems and the message is received by teh Web Service.
    If modify the file XSL into the BIU, a message with less elements than a schema pass without problem.
    If delete the schema from repository, the message pass without validation.
    I would know because the schema is bypassed...
    Thans

    Ok,
    solved with introduction of validation point in a customized IPO using a branch / unbranch atoms.
    Bye.

  • Can a change be made to the original Word document without losing form fields in a saved PDF form?

    I have a new fillable form created with Acrobat 9 that has 10 pages of fields on it. I noticed a typo in the original Word doc I created the form from and wondered if there is anyway to make changes in the source document without having to recreate all fields again.
    Thanks!
    Frank

    Yes, just create a new PDF and replace the pages of the old one that has the form fields with the pages from the new: Document > Replace Pages
    Any fields, code, bookmarks, links, etc. will be retained.

  • A word document was emailed to me.  I can open the document without a problem.  Is there a way for me to type on the document.... to fill out the form?  When I click the fields, the virtual keyboard does not appear.

    A word document was emailed to me.  I can open the document without a problem on my iPad 2.   Is there a way for me to type on the document.... to fill out the form?  When I click the fields, the virtual keyboard does not appear.

    If you want to edit a word document then you will need an app on your iPad that supports word so that you can copy them to it via 'open in' e.g. Apple's Pages app or a third-party app such as Documents To Go or QuickOffice HD

  • How to update profit center in posted document without profit center ?

    HI,
    I want to know,
    How to update profit center in posted document without profit center ?
    So that i can get my profit center accouting report proper.
    Thanks
    Nilesh

    There is a long story about profit center accounting. I assume you are using Classic PCA, this means you can see the PCA documents.  And the solutions is below:
         For P/L account, even you don't maintain cost element for it, if you maintain the profit center in the application (Frontend transaction), then PCA line items will be generated for this account.
        For B/S account,  if you maintain the default Profit Center with transaction 3KEH/3KEI, the PCA line items will generated for this account also.
      Hints, don't maintain default profit center for AR/AP accounts, these accounts to be treated in periodic processing.
      First, calculate the distribution/adjust by F.5D, then transfer it by 1KEK. for others account rather than AR/AP, use F.5E
    For you case, if this account is P/L account, but you don't maintain profit center in the transaction, you can maintain default profit center as B/S account in 3KEH and 3KEI, then transfer it subsequently by transaction 1KE8.
    Good Lucky!
    Flex Yang

Maybe you are looking for

  • In which table to find parked, cleared and open invoices?

    in FI how to know which table stores parked , open and cleared invoices? if through FBL1N, what is the way ? thanks

  • How to get photos from iphone5 with unresponsive screen

    My iphone was dropped a few days ago and the screen became unresponsive. All the buttons work fine, but I can't swipe to turn it on or enter my passcode. I took the phone to an Apple store and was told by a not-nice guy that there was nothing they co

  • Financial Reporting Client

    Hi All, I have installed HFR client on my system and i did configure also.(Registration with Shared services, database configure,application server and web server). When try to login with admin and password, it is not authenticating. Login window doe

  • Function module L_INV_COUNT_EXT

    Hi, We are calling the above FM L_INV_COUNT_EXT using a remote function call. However, the count remains locked on ELLINKE for quite some time after we finished processing the FM. When we run this function in SAP using SE37 we notice that the lock on

  • Universe Connection in Business Objects for SAP BW as Source.

    Hi All, I am trying to create a new Universe connection where i took SAP  as a source , I filled all the details that is required for connection like Application server and system number. when i click on next it showing a error like this-- businessob