473,729 Members | 2,348 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\h ome
Canonicalpath-Directory4: \\wkdis3\ROOT\h ome\bwe\
You selected the file named AAA.XML
getXmlAlgorithm Document(): IOException Not logged in

sun.net.ftp.Ftp LoginException: Not logged in
at sun.net.ftp.Ftp Client.readRepl y(Unknown Source)
at sun.net.ftp.Ftp Client.issueCom mand(Unknown Source)
at sun.net.ftp.Ftp Client.login(Un known 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.xerc es.impl.XMLEnti tyManager.setup CurrentEntity(U nknown
Source)
at org.apache.xerc es.impl.XMLVers ionDetector.det ermineDocVersio n(Unknown
Source)
at org.apache.xerc es.parsers.XML1 1Configuration. parse(Unknown Source)
at org.apache.xerc es.parsers.XML1 1Configuration. parse(Unknown Source)
at org.apache.xerc es.parsers.XMLP arser.parse(Unk nown Source)
at org.apache.xerc es.parsers.DOMP arser.parse(Unk nown Source)
at org.apache.xerc es.jaxp.Documen tBuilderImpl.pa rse(Unknown Source)
at javax.xml.parse rs.DocumentBuil der.parse(Unkno wn Source)
at ParseTest.<init >(ParseTest.jav a: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.IOExcep tion;
//import java.util.HashM ap;
//import java.util.Map;

import javax.swing.JFi leChooser;
import javax.xml.parse rs.DocumentBuil der;
import javax.xml.parse rs.DocumentBuil derFactory;
import javax.xml.parse rs.ParserConfig urationExceptio n;

//import org.apache.exca libur.source.So urceParameters;
//import org.apache.exca libur.source.So urceResolver;
import org.w3c.dom.Doc ument;
import org.xml.sax.Err orHandler;
import org.xml.sax.SAX Exception;
import org.xml.sax.SAX ParseException;

import com.ibm.as400.a ccess.AS400;
import com.ibm.as400.a ccess.IFSJavaFi le;
import com.ibm.as400.v access.IFSFileS ystemView;

public class ParseTest {

private File file;

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

DocumentBuilder Factory factory =DocumentBuilde rFactory.newIns tance();
//Logging with anonymus user,resolving ftp source
//ftp://user:password@( protected):port/path
/* SourceParameter s params = new SourceParameter s();
params.setParam eter("user", "anonymous" );
params.setParam eter("password" , "");
Map map = new HashMap();
map.put(SourceR esolver.URI_PAR AMETERS, params);
targetSrc = resolver.resolv eURI("http://xml.org/sax/features/validation",
null,map);
*/
// set attributes for validation (including xml schema)
try {
// factory.setAttr ibute(targetSrc , new Boolean(true));
factory.setAttr ibute("http://xml.org/sax/features/validation", new
Boolean(true));
factory.setAttr ibute("http://apache.org/xml/features/validation/schema",
new Boolean(true));

factory.setVali dating(true);
}catch (IllegalArgumen tException e) {
// thrown if the underlying implementation doesn't recognize the
attributes
System.out.prin tln("Underlying implementation doesn't recognize
the attribute.");
System.out.prin tln("getXmlAlgo rithmDocument() :IllegalArgumen tException
" + e.getMessage()+ "\n");
e.printStackTra ce();
//return null;
}
DocumentBuilder builder = null;
Document doc = null;
ErrorHandler errorHandler = new MyErrorHandler( );


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

}
catch (ParserConfigur ationException e) {
System.out.prin tln("getXmlAlgo rithmDocument() :ParserConfigur ationException
" + e.getMessage()+ "\n");
e.printStackTra ce();
// return null;
}

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

}
catch (SAXParseExcept ion e) {
System.out.prin tln("\n** Parsing error" + ", line " +
e.getLineNumber ()
+ ", uri " + e.getSystemId() );
System.out.prin tln("getXmlAlgo rithmDocument() : SAXParseExcepti on "
+ e.getMessage()+ "\n");
e.printStackTra ce();
// return null;
}
catch (SAXException e) {
// parser throws SAXException ,If any parse errors occur
System.out.prin tln("getXmlAlgo rithmDocument() : SAXException " +
e.getMessage()+ "\n");
e.printStackTra ce();
// return null;
}
catch (IOException e) {
// parser throws IOException
System.out.prin tln("getXmlAlgo rithmDocument() : IOException " +
e.getMessage()+ "\n");
e.printStackTra ce();
// return null;
}
catch (IllegalArgumen tException e) {
// parser throws IllegalArgument Exception, If the file is null
System.out.prin tln("getXmlAlgo rithmDocument() :
IllegalArgument Exception " +
e.getMessage()+ "\n");
e.printStackTra ce();
// 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(sys tem, "//wkdis3/ROOT/home/bwe/");
String directory0 = dir.getParent() ;
System.out.prin tln ("Directory0 : " + directory0);
String directory4=dir. getCanonicalPat h();
System.out.prin tln ("Canonicalp ath-Directory4: " + directory4);
// IFSJavaFile dir = new IFSJavaFile( "\\wkdis3\ROOT\ home\bwe");
JFileChooser chooser = new JFileChooser(di r, new
IFSFileSystemVi ew(system));
Frame parent = new Frame();

int returnVal = chooser.showOpe nDialog(parent) ;

if (returnVal == JFileChooser.AP PROVE_OPTION) {

IFSJavaFile chosenFile =
(IFSJavaFile)(c hooser.getSelec tedFile());

System.out.prin tln("You selected the file named " +
chosenFile.getN ame());
String filename = chosenFile.getN ame();

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

}

}

class MyErrorHandler implements ErrorHandler {

/
public void warning(SAXPars eException exception) throws SAXException
{
System.out.prin tln("**Parsing Warning**\n" +
" Line: " +exception.getL ineNumber() + "\n" +
" URI: " +exception.getS ystemId() + "\n" +
" Message: " +exception.getM essage());
throw new SAXException("W arning encountered");

}

public void error(SAXParseE xception exception) throws SAXException {
System.out.prin tln("**Parsing Error**\n" +
" Line: " +exception.getL ineNumber() + "\n" +
" URI: " +exception.getS ystemId() + "\n" +
" Message: " +exception.getM essage());
throw new SAXException("E rror encountered");
}

public void fatalError(SAXP arseException exception) throws
SAXException {
System.out.prin tln("**Parsing Fatal Error**\n" +
" Line: " +exception.getL ineNumber() + "\n" +
" URI: " +exception.getS ystemId() + "\n" +
" Message: " +exception.getM essage());
throw new SAXException("F atal Error encountered");
}

}
Jul 20 '05 #1
2 3956
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\h ome
Canonicalpath-Directory4: \\wkdis3\ROOT\h ome\bwe\
You selected the file named AAA.XML
getXmlAlgorithm Document(): IOException Not logged in

sun.net.ftp.Ftp LoginException: Not logged in
at sun.net.ftp.Ftp Client.readRepl y(Unknown Source)
at sun.net.ftp.Ftp Client.issueCom mand(Unknown Source)
at sun.net.ftp.Ftp Client.login(Un known 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
3069
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 events can then I am able to parse XML input in the form of files. I also have provided support for parsing of XML content in the form of string data. I am able to do so by creating a MemBufInputSource object using the XML content provided to the...
3
2762
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. In the samples/data directory, I ran the following command for all the files: DOMPrint -n -s -f -v=always <filename>
8
2704
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
10287
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 purpose I set the corresponding XercesDOMParser feature as shown in the upcoming subsection of my code. As far as I understand, the parsing process should throw an DOMException in case the XML file doesn't match the Schema file (e.g. Element...
24
2496
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 </foo> becomes <fooblabla bla </foo>
2
3519
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 essential to determine the charset encoding which is usually indentified within the header of the XML file e.g. <?xml version="1.0" encoding="UTF-8" ?> After a query in the xerces-c API documentation I guess that: - XMLDecl(const XMLCh *const...
2
2160
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 to the ElementNSImpl class, I do: myElement = doc.createElement('elementName') docRootNode.appendChild(myElement)
4
1945
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. #include <xercesc/dom/deprecated/DOMParser.hpp> #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/dom/DOM_Document.hpp> #include <xercesc/dom/deprecated/DOM_DOMException.hpp> #include...
1
3501
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 especially czech,polish,turkish in place of local language character some other word is comming. Eg: Input string :ahoj, jak se máš Output string :ahoj, jak se m&aacute;š
0
8917
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9142
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4795
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.