473,218 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,218 software developers and data experts.

XML file parsing/validating with xerces-j

Hello,

I am trying to parse the XML files that the user selects(XML files are
on anoher OS400 system called "wkdis3"). But i am permenantly getting
that error:

Directory0: \\wkdis3\ROOT\home
Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\
You selected the file named AAA.XML
getXmlAlgorithmDocument(): IOException Not logged in

sun.net.ftp.FtpLoginException: Not logged in
at sun.net.ftp.FtpClient.readReply(Unknown Source)
at sun.net.ftp.FtpClient.issueCommand(Unknown Source)
at sun.net.ftp.FtpClient.login(Unknown Source)
at sun.net.http://www.protocol.ftp.FtpURLConnec...onnect(Unknown Source)
at sun.net.http://www.protocol.ftp.FtpURLConnec...Stream(Unknown
Source)
at org.apache.xerces.impl.XMLEntityManager.setupCurre ntEntity(Unknown
Source)
at org.apache.xerces.impl.XMLVersionDetector.determin eDocVersion(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse (Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(U nknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at ParseTest.<init>(ParseTest.java:110)
at ParseTest.main(ParseTest.java:221)

Below is my sourcefile ParseTest.java..Does anyone any idea about how
to fix that IOException with ftp..for validating xerces i had to set
some feautures from an URI. I thought maybe that could be the
reason.Any idea?

import java.io.File;
import java.io.IOException;
//import java.util.HashMap;
//import java.util.Map;

import javax.swing.JFileChooser;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;

//import org.apache.excalibur.source.SourceParameters;
//import org.apache.excalibur.source.SourceResolver;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;

import com.ibm.as400.access.AS400;
import com.ibm.as400.access.IFSJavaFile;
import com.ibm.as400.vaccess.IFSFileSystemView;

public class ParseTest {

private File file;

public ParseTest(File file)
{
this.file=file;

DocumentBuilderFactory factory =DocumentBuilderFactory.newInstance();
//Logging with anonymus user,resolving ftp source
//ftp://user:password@(protected):port/path
/* SourceParameters params = new SourceParameters();
params.setParameter("user", "anonymous");
params.setParameter("password", "");
Map map = new HashMap();
map.put(SourceResolver.URI_PARAMETERS, params);
targetSrc = resolver.resolveURI("http://xml.org/sax/features/validation",
null,map);
*/
// set attributes for validation (including xml schema)
try {
// factory.setAttribute(targetSrc, new Boolean(true));
factory.setAttribute("http://xml.org/sax/features/validation", new
Boolean(true));
factory.setAttribute("http://apache.org/xml/features/validation/schema",
new Boolean(true));

factory.setValidating(true);
}catch (IllegalArgumentException e) {
// thrown if the underlying implementation doesn't recognize the
attributes
System.out.println("Underlying implementation doesn't recognize
the attribute.");
System.out.println("getXmlAlgorithmDocument():Ille galArgumentException
" + e.getMessage()+ "\n");
e.printStackTrace();
//return null;
}
DocumentBuilder builder = null;
Document doc = null;
ErrorHandler errorHandler = new MyErrorHandler();


try {
// get an instance of a builder
builder = factory.newDocumentBuilder();
// Register the error handler
builder.setErrorHandler(new MyErrorHandler());//If an application
does not register an ErrorHandler, XML parsing errors will go
unreported and bizarre behaviour may result.

}
catch (ParserConfigurationException e) {
System.out.println("getXmlAlgorithmDocument():Pars erConfigurationException
" + e.getMessage()+ "\n");
e.printStackTrace();
// return null;
}

try {
// parse the algorithm file and get document
doc = builder.parse(file);

}
catch (SAXParseException e) {
System.out.println("\n** Parsing error" + ", line " +
e.getLineNumber()
+ ", uri " + e.getSystemId());
System.out.println("getXmlAlgorithmDocument(): SAXParseException "
+ e.getMessage()+ "\n");
e.printStackTrace();
// return null;
}
catch (SAXException e) {
// parser throws SAXException ,If any parse errors occur
System.out.println("getXmlAlgorithmDocument(): SAXException " +
e.getMessage()+ "\n");
e.printStackTrace();
// return null;
}
catch (IOException e) {
// parser throws IOException
System.out.println("getXmlAlgorithmDocument(): IOException " +
e.getMessage()+ "\n");
e.printStackTrace();
// return null;
}
catch (IllegalArgumentException e) {
// parser throws IllegalArgumentException, If the file is null
System.out.println("getXmlAlgorithmDocument():
IllegalArgumentException " +
e.getMessage()+ "\n");
e.printStackTrace();
// return null;
}

}
public static void main(String[] args) throws IOException {
// Work with /Dir/File.txt on the system wkdis3.
AS400 system = new AS400("wkdis3");
IFSJavaFile dir = new IFSJavaFile(system, "//wkdis3/ROOT/home/bwe/");
String directory0 = dir.getParent();
System.out.println ("Directory0: " + directory0);
String directory4=dir.getCanonicalPath();
System.out.println ("Canonicalpath-Directory4: " + directory4);
// IFSJavaFile dir = new IFSJavaFile( "\\wkdis3\ROOT\home\bwe");
JFileChooser chooser = new JFileChooser(dir, new
IFSFileSystemView(system));
Frame parent = new Frame();

int returnVal = chooser.showOpenDialog(parent);

if (returnVal == JFileChooser.APPROVE_OPTION) {

IFSJavaFile chosenFile =
(IFSJavaFile)(chooser.getSelectedFile());

System.out.println("You selected the file named " +
chosenFile.getName());
String filename = chosenFile.getName();

// XML files are here:("\\wkdis3\ROOT\home\bwe\AABB.XML");
//IFSJavaFile file = new IFSJavaFile(system,directory4+filename);
//File f=file;
File f=new File(directory4+filename);
ParseTest xIncludeTest = new ParseTest(f);
}

}

}

class MyErrorHandler implements ErrorHandler {

/
public void warning(SAXParseException exception) throws SAXException
{
System.out.println("**Parsing Warning**\n" +
" Line: " +exception.getLineNumber() + "\n" +
" URI: " +exception.getSystemId() + "\n" +
" Message: " +exception.getMessage());
throw new SAXException("Warning encountered");

}

public void error(SAXParseException exception) throws SAXException {
System.out.println("**Parsing Error**\n" +
" Line: " +exception.getLineNumber() + "\n" +
" URI: " +exception.getSystemId() + "\n" +
" Message: " +exception.getMessage());
throw new SAXException("Error encountered");
}

public void fatalError(SAXParseException exception) throws
SAXException {
System.out.println("**Parsing Fatal Error**\n" +
" Line: " +exception.getLineNumber() + "\n" +
" URI: " +exception.getSystemId() + "\n" +
" Message: " +exception.getMessage());
throw new SAXException("Fatal Error encountered");
}

}
Jul 20 '05 #1
2 3879
cs*******@gmail.com (Cigdem) writes:
I am trying to parse the XML files that the user selects(XML files are
on anoher OS400 system called "wkdis3"). But i am permenantly getting
that error:

Directory0: \\wkdis3\ROOT\home
Canonicalpath-Directory4: \\wkdis3\ROOT\home\bwe\
You selected the file named AAA.XML
getXmlAlgorithmDocument(): IOException Not logged in

sun.net.ftp.FtpLoginException: Not logged in
at sun.net.ftp.FtpClient.readReply(Unknown Source)
at sun.net.ftp.FtpClient.issueCommand(Unknown Source)
at sun.net.ftp.FtpClient.login(Unknown Source)

Appears to be an athentication problem, nothing to do with XML. Check
that username and passwords are correctly sent to the server.

-- Alain.

P/S (perso): Merhaba Cigdem. Mes salutations de Strasbourg.
Jul 20 '05 #2

Bonjour :)

I solved the problem, as you have told it was a problem of
authentication.. Thanks again for the reply.

PS: C'est un suprise très beaux de vous rencontrer dans l'Internet.
J'habite maintenant en Allemagne, mais je manque beaucoup d'Istanbul.
Maintenant je dois apprendre et parler toujours l'Allemand. En raison de
cela, mon français est un peu plus mauvais maintenant. Je devine que
vous travaillez à l'université de Strousburg en ce moment. Je vous
souhaite des bonnes chances:)

Cigdem Savaseri-Brackmann

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Girish | last post by:
Hi All, I have written a component(ATL COM) that wraps Xerces C++ parser. I am firing necessary events for each of the notifications that I have handled for the Content and Error handler. The...
3
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question....
8
by: pradeepsarathy | last post by:
Hi all, Does the SAX parser has eventhandlers for parsing xml schema. Can we parse the xml schema the same way as we parse the xml document using SAX Parser. Thanks in advance. -pradeep
7
by: christian.eickhoff | last post by:
Hi Everyone, I am currently implementing an XercesDOMParser to parse an XML file and to validate this file against its XSD Schema file which are both located on my local HD drive. For this...
24
by: Marc Dubois | last post by:
hi, is it possible to parse an XML file in C so that i can fulfill these requirements : 1) replace all "<" and ">" signs inside the body of tag by a space, e.g. : Example 1: <fooblabla < bla...
2
by: christian.eickhoff | last post by:
Hello Everyone, I am facing a problem which should be relatively easy to solve for XML or XERCES experts. I am parsing my XML instance using xerces-c SAXParser. For internal purposes, it is...
2
by: redcic | last post by:
Hi all, I would like to build a xml file using Xerces. I know how to build a single node at a time. For example, with 'doc' belonging to the DocumentImpl class and with 'docRootNode' belonging...
4
by: Arengin | last post by:
HI everyone, I am new with Xerces-C but I managed to get a DOMTree runing and to extracte the data to the screen. However I need to write the Tree back to a file.... and this is where I am stuck. ...
1
by: Sidhartha | last post by:
Hi, I am facing a problem while parsing local language characters using sax parser. We use DOM to parse and SAX to read the source. But when our application parses strings with local language...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.