Looking for a quick well-formedness tool for Linux

C

Cambridge Ray

I have found all kinds of nice tools, freebies and commercial (Stylus
Studio) for the Windows side, but find myself uploading and
downloading XML files between Windows and Linux. I do my development
(Xerces-C++) on the latter.

Could really use a SIMPLE Linux app that tells me whether an XML file
is well-formed, period. I don't even use schemas and all that fancy
stuff.

TIA,

-RFH
 
M

Martin Honnen

Cambridge said:
I have found all kinds of nice tools, freebies and commercial (Stylus
Studio) for the Windows side, but find myself uploading and
downloading XML files between Windows and Linux. I do my development
(Xerces-C++) on the latter.

Could really use a SIMPLE Linux app that tells me whether an XML file
is well-formed, period. I don't even use schemas and all that fancy
stuff.

Doesn't
xmllint file.xml
do what you want? I thought libxml2 and its tool are part of LINUX these
days.
 
C

Cambridge Ray

Doesn't
   xmllint file.xml
do what you want? I thought libxml2 and its tool are part of LINUX these
days.

Great!

(and I didn't have to download & compile anything)

Thx,

-Ramon
 
L

Luuk

I have found all kinds of nice tools, freebies and commercial (Stylus
Studio) for the Windows side, but find myself uploading and
downloading XML files between Windows and Linux. I do my development
(Xerces-C++) on the latter.

Could really use a SIMPLE Linux app that tells me whether an XML file
is well-formed, period. I don't even use schemas and all that fancy
stuff.

TIA,

-RFH

http://xmlstar.sourceforge.net/
 
P

Peter Flynn

I have found all kinds of nice tools, freebies and commercial (Stylus
Studio) for the Windows side, but find myself uploading and
downloading XML files between Windows and Linux. I do my development
(Xerces-C++) on the latter.

Could really use a SIMPLE Linux app that tells me whether an XML file
is well-formed, period. I don't even use schemas and all that fancy
stuff.

Any of the standard commandline parsers will do this.
I use onsgmls (from the OpenSP package) and rxp, but there are many others.

///Peter
 
J

Joe Kesselman

Could really use a SIMPLE Linux app that tells me whether an XML file
is well-formed, period. I don't even use schemas and all that fancy
stuff.

Any of the nonvalidating Xerces sample programs could be trivially
adapted for this purpose. Parse the document, discard the DOM (or the
SAX events), and report success or failure of the parse.


--
Joe Kesselman,
http://www.love-song-productions.com/people/keshlam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
M

Manuel Collado

El 27/07/2011 18:22, Cambridge Ray escribió:
I have found all kinds of nice tools, freebies and commercial (Stylus
Studio) for the Windows side, but find myself uploading and
downloading XML files between Windows and Linux. I do my development
(Xerces-C++) on the latter.

Could really use a SIMPLE Linux app that tells me whether an XML file
is well-formed, period. I don't even use schemas and all that fancy
stuff.

The expat parser includes the 'xmlwf' utility that do just that.
 
C

Cambridge Ray


"Dear XMLStarlet users,
you may have noticed that the development of xmlstarlet has somewhat
stalled. To get the submitted patches applied I volunteered to co-
admin the project and at least do some maintenance work. Unfortunetaly
my time is limited and I would like to call for participation."

-RFH
 
L

Luuk

"Dear XMLStarlet users,
you may have noticed that the development of xmlstarlet has somewhat
stalled. To get the submitted patches applied I volunteered to co-
admin the project and at least do some maintenance work. Unfortunetaly
my time is limited and I would like to call for participation."

-RFH

But it stil can check for well-formedness ..... ;)
 
J

Joe Kesselman

Swiping from one of the many examples on DeveloperWorks
(http://www.ibm.com/xml):

public class TestSAXParsing {
public static void main(String[] args) {
try {
if (args.length != 1) {
System.err.println(
"Usage: java TestSAXParsing [filename]");
System.exit (1);
}
// Get SAX Parser Factory
SAXParserFactory factory = SAXParserFactory.newInstance();

// Turn off validation, and turn on namespaces
// (the latter, at least, is probably the default)
factory.setValidating(falsee);
factory.setNamespaceAware(true);

// Parse the file, discard via a no-op SAX handler
SAXParser parser = factory.newSAXParser();
parser.parse(new File(args[0]), new MyHandler());
} catch (ParserConfigurationException e) {
System.out.println("Underlying parser does not support" +
" the requested features.");
} catch (FactoryConfigurationError e) {
System.out.println("Error obtaining SAX Parser Factory.");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(
"Parsing completed; XML document well-formed.");
}
}

class MyHandler extends DefaultHandler {
// No-op implementation of ContentHandler, ErrorHandler, etc.
}

--
Joe Kesselman,
http://www.love-song-productions.com/people/keshlam/index.html

{} ASCII Ribbon Campaign | "may'ron DaroQbe'chugh vaj bIrIQbej" --
/\ Stamp out HTML mail! | "Put down the squeezebox & nobody gets hurt."
 
P

Peter Flynn

Swiping from one of the many examples on DeveloperWorks
(http://www.ibm.com/xml):

public class TestSAXParsing {
public static void main(String[] args) {
try {
if (args.length != 1) {
System.err.println(
"Usage: java TestSAXParsing [filename]");
System.exit (1);
}
// Get SAX Parser Factory
SAXParserFactory factory = SAXParserFactory.newInstance();

// Turn off validation, and turn on namespaces
// (the latter, at least, is probably the default)
factory.setValidating(falsee);
factory.setNamespaceAware(true);

// Parse the file, discard via a no-op SAX handler
SAXParser parser = factory.newSAXParser();
parser.parse(new File(args[0]), new MyHandler());
} catch (ParserConfigurationException e) {
System.out.println("Underlying parser does not support" +
" the requested features.");
} catch (FactoryConfigurationError e) {
System.out.println("Error obtaining SAX Parser Factory.");
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(
"Parsing completed; XML document well-formed.");
}
}

class MyHandler extends DefaultHandler {
// No-op implementation of ContentHandler, ErrorHandler, etc.
}

I'll stick with
$ rxp filename.xml
thanks :)

///Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top