How To check validity of XML File
can any one tell me how to find whether an XML file is valid or not before beginning to parse the XML file
Thanks in advance
Xerces will do that for qou, if you activate validation (and, of course, a DTD is specified in the file). Read the documentation of Xerces at xml.apache.org
Similar Messages
-
Newbie help please: "Validation of XML file failed."
Hopefully my question is short and easy.
I'm a developer and haven't used FrameMaker before. However for unforeseen reasons, I've inherited our technical help documentation constructed in FrameMaker which I've never used. Unfortunately I'm under a very tight deadline and I'm attempting to update our already existing and fairly extensive application help files.
However, I'm getting a "Validation of XML file failed" error for 90% of our .xml help docs. I opened our .book file in FrameMaker fairly easily, and can see all of our .xml files. However the variables already embedded in the documents aren't being recognized and seem to be causing the above error. I've located our variable definition files (xml) in the concepts folder, but FrameMaker doesn't seem to recognize them. Any suggestions on what I can check or how I can get FM to refer to the variable definitions? I'm working with a new installation of FM, is there some setup I overlooked?
Many thanks,
dana.Sheila and Rick,
Thank you both so much for your offer of help. My apologies for not replying earlier. Other 'emergencies' and priorities at work took me in other directions. It turns out another solution has been found for the time being. But thank you again for your replies. They say a lot about this community and its support. :)
Thanks again,
dana. -
How to retrieve value from xml file
hi all,
can somebody pls tell me how to retrieve value from xml file using SAXParser.
I want to retrieve value of only one tag and have to perform some validation with that value.
it's urgent .
pls help me out
thnx in adv.
rituhi shanu,
the pbm is solved, now i m able to access XXX no. in action class & i m able to validate it. The only thing which i want to know is it ok to declare static ArrayList as i have done in this code. i mean will it affect the performance or functionality of the system.
pls have a look at the following code snippet.
public class XMLValidator {
static ArrayList strXXX = new ArrayList();
public void validate(){
factory.setValidating(true);
parser = factory.newSAXParser();
//all factory code is here only
parser.parse(xmlURI, new XMLErrorHandler());
public void setXXX(String pstrXXX){
strUpn.add(pstrXXX);
public ArrayList getXXX(){
return strXXX;
class XMLErrorHandler extends DefaultHandler {
String tagName = "";
String tagValue = "";
String applicationRefNo = "";
String XXXValue ="";
String XXXNo = "";
XMLValidator objXmlValidator = new XMLValidator();
public void startElement(String uri, String name, String qName, Attributes atts) {
tagName = qName;
public void characters(char ch[], int start, int length) {
if ("Reference".equals(tagName)) {
tagValue = new String(ch, start, length).trim();
if (tagValue.length() > 0) {
RefNo = new String(ch, start, length);
if ("XXX".equals(tagName)) {
XXXValue = new String(ch, start, length).trim();
if (XXXValue.length() > 0) {
XXXNo = new String(ch, start, length);
public void endElement(String uri, String localName, String qName) throws SAXException {
if(qName.equalsIgnoreCase("XXX")) {
objXmlValidator.setXXX(XXXNo);
thnx & Regards,
ritu -
How can (parse) i use XML file with missing EndTag
hi,
i have an application which writes an "XML file".
another application should read that XML file, build an DOM and
access the nodes with xpath.
my problem. if the first application is not finished there are tags
missing. e.g. </xml>. but the seconds application cannot wait until the first application finishes it task.
if i now read the XML file the parser cannot load it because the end tags are missing.
my question:
how can i deactivate the check or how can i read the XML file and access it via XPath (my application is using at the moment XPath to access the nodes and i dont want to change that)
as parser i am using XERCES
alexAs far as I know, you can't do this - xml must be well formed (this is sort of a bedrock of xml). There may be some work around's, but I'm not aware of any - and they would most likely be hacks.
-
How do I Ftp a XML file with out namespace attribute
Hi All,
How do I FTP an xml file that is validated against a schema on the ftp adapter with out the namespace attribute being added to the first and second element of the XML file.
For example the xml looks like this when I transfer the file.
<XML_Event xmlns="http://xmlns.oracle.com/PlannedEventSTORMRequestProcess/STORM">
<Event_Begin xmlns="">
<XML_File_Header>
<Originating_System>xxx</Originating_System>
<ID>387</ID>
</XML_File_Header>
</Event_Begin>
</XML_Event>
However I want it to be….
<XML_Event>
<Event_Begin>
<XML_File_Header>
<Originating_System>xxx</Originating_System>
<ID>387</ID>
</XML_File_Header>
</Event_Begin>
</XML_Event>
How do i achieve this using the ftp adapter.
CheersHere is an example that will try to reach the given size in steps of 4 in quality.
var saveFile = File(Folder.desktop + "/test");
var fileSize = 70;
try{
tmpFile = File(saveFile+".jpg");
for(var z =100;z>5;z -=4){
SaveForWeb(tmpFile,z);
var chkFile = File(saveFile+".jpg");
//$.writeln(tmpFile + " qual = " + z + " Size = " +(chkFile.length/1024).toFixed(2) + "k" );
if((chkFile.length/1024).toFixed(2) < (fileSize +1)) break;
tmpFile.remove();
if(!tmpFile.exists) SaveForWeb(tmpFile,5);
}catch(e){$.writeln(e + " - " + e.line);}
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = false;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = Number(jpegQuality);
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions); -
How I can create a XML file from java Aplication
How I can create a XML file from java Aplication
whith have a the following structure
<users>
<user>
<login>anyName</login>
<password>xxxx</password>
</user>
</users>
the password label must be encripted
accept any suggestionLet us assume you have all the data from the jsp form in an java bean object..
Now you want a xml file. This can be acheived in 2 ways
1. Write it into a file using java.io classes. Say you have a class with name
write("<name>"+obj.getName+</name>);
bingo you have a flat file with the xml
2. Use data binding to do the trick
will recommend JiBx and Castor for the 2nd option
Regards,
Rajagopal -
How to Read and Generate XML file from java code.
hi guys,
how to read the xml file (Condition :we know only DTD or Shema only).
How to Generate the new xml file ?(using Shema )
And one more how directly Generate the xml from DB?
Pleas with code or any URLUsing XMLbeans you can generate Java objects from an XSD schema (perhaps DTDs aswell)
Then you can create an instance of the Document object and ask it to write itself.
This will create an XML document complient to the schema.
XMLBeans generates a "type" safe DOM where you can only ever have a structure compilent to you schema.
matfud -
How I could generate an XML file from a report in version 4.0B
Good morning,
How could I generate an XML file from a report? Please note that I am using version 4.0B
I don't have access to
Billy VitalHi,
In the Class CL_XML_DOCUMENT,
we have a method EXPORT_TO_FILE to download an XML file. -
How to remove Unicode from XML file
I get following error when unmarshal xml:
[java] org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x15) was found in the element content of the document.
Anyone know how to remove Unicode from xml file? Can I remove the unicode by rebuild the file?
ThanksThese sort of error usually occur when you're using a different character encoding to read the file than the one you wrote it with. Perhaps if you were to post the problem section of the file and/or the code that created it in the first place.
-
How to parse contents from XML file in Java
Hi All,
I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
How to parse Contents of XML file??
Thanks in advance,
Rajendra.Hi All,
I have a scenario like this . I have one xml file with key value pairs of ( name , URL ) . I have retrieved contents from XML file , now I want to parse these contents and store in a bean object.
How to parse Contents of XML file??
Thanks in advance,
Rajendra. -
How do I create individual xml files from the parsed data output of a xml file?
I have written a program (DOM Parser) that parses data from a XMl File. I would like to create an individual file with the corresponding name for each set of data parsed from the xml document. If the parsed output is Single, Double, Triple, I would like to create an individual xml file (Single.xml, Double.xml, Triple.xml)with those corresponding names. How do I create the xml files and give each file the name of my parsed data output? Thanks in advance for your help.
import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class MyDomParser {
public static void main(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("ENtemplate.xml");
doc.normalize();
NodeList rootNodes = doc.getElementsByTagName("templates");
Node rootNode = rootNodes.item(0);
Element rootElement = (Element) rootNode;
NodeList templateList = rootElement.getElementsByTagName("template");
for(int i=0; i < templateList.getLength(); i++) {
Node theTemplate = templateList.item(i);
Element templateElement = (Element) theTemplate;
System.out.println("Template" + ": " +templateElement.getAttribute("name")+ ".xml");
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();Ive posted the new code but now I'm getting a FileAlreadyExistException error. How do I handle this exception error correctly in my code?
import java.io.IOException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class MyDomParser {
public static void main(String[] args) {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder builder = factory.newDocumentBuilder();
Document doc = builder.parse("ENtemplate.xml");
doc.normalize();
NodeList rootNodes = doc.getElementsByTagName("templates");
Node rootNode = rootNodes.item(0);
Element rootElement = (Element) rootNode;
NodeList templateList = rootElement.getElementsByTagName("template");
for(int i=0; i < templateList.getLength(); i++) {
Node theTemplate = templateList.item(i);
Element templateElement = (Element) theTemplate;
System.out.println(templateElement.getAttribute("name")+ ".xml");
for(int i=0; i < templateList.getLength(); i++) {
Node theTemplate = templateList.item(i);
Element templateElement = (Element) theTemplate;
String fileName = templateElement.getAttribute("name") + ".xml";
Files.createFile(Paths.get(fileName));
System.out.println("File" + ":" + fileName + ".xml created");
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace(); -
How to config the web.xml file, when I use Richfaces + RI 1.2?
Hi there:
I want to use Richfaces + RI 1.2 to build a project. I don`t know how to config the web.xml file.
By the way, my web server is Tomcat 6.0, my JDK's version is 6u6. I don`t want to use the facelets.
thanks.
lxmjust add this before *</web-app>*
<context-param>
<param-name>org.richfaces.SKIN</param-name>
<param-value>blueSky</param-value>
</context-param>
<filter>
<display-name>RichFaces Filter</display-name>
<filter-name>richfaces</filter-name>
<filter-class>org.ajax4jsf.Filter</filter-class>
</filter>
<filter-mapping>
<filter-name>richfaces</filter-name>
<servlet-name>Faces Servlet</servlet-name>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
<dispatcher>INCLUDE</dispatcher>
</filter-mapping> -
How to extract data from XML file with JavaScript
HI All
I am new to this group.
Can anybody help me regarding XML.
I want to know How to extract data from XML file with JavaScript.
And also how to use API for XML
regards
NagarajuThis is a Java forum.
JavaScript is something entirely different than Java, even though the names are similar.
Try another website with forums about JavaScript.
For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3 -
How do I upload an XML file to salesforce using BULK API?
Hi There,
Please let me know how do we upload an XML file to salesforce using Bulk API?
Thanks,
ETHi,
I think that this is a more SalesForce.com question and think you will have more chance looking at SOAP API Developer's Guide for salesforce. Sending a SOAP request from the API Server is very straight forward and there are several tutorials and well documented about this.
Cheers,
Stefan -
How can I pass a xml file to the webservice?
Hello friends,
How can I pass the XML file to any webservice API ?
I have all the inputs of API in to the XML file.
Please note:- I don't intend to do any .NET or Java coding to populate the data in the objects .Instead I plan to input the data to the webservice direcly from the XML file required schema.
If necessary I can use Oracle Bpel process manager for it.
Thanks and regards
Ram Krishna Tripathi
[email protected]Well, I've used it (or rather: tried it); did not/could not find the many options to export at a nearly lossless conversion for HD footage (hence my disclaimer "don't know"). Here is a screenshot of the Handbrake options:
And here are the choices and settings from MPEG Streamclip:
Maybe not empirical, but enough for me to have an opinion.
Maybe you are looking for
-
Web form fields not staying in order
Does anyone know why the fields in my forms keep re-arranging themselves. For example I will move "Field 2" below "Field 6" and everything looks like it works but when I insert the form on a page the fields are not in the order I set. Any advice?
-
I keep getting these "visual match" ads, pop ups, and redirect tabs. Its never happen before until a couple of days ago. I use chrome and my macbook is up to date. Is there anyway I can get rid of these without having to buy anything?
-
Installing CS2 so I can install cs4 upgrade on windows 7
I just got a new pc has windows 7 pro OS and need to install my adobe CS. I have CS2 with a CS4 upgrade. As you can probably guess i am having trouble getting the cs to install. I would like to upgrade to cs 5.5 but if I cant get the cs 2 on to upgr
-
Good morning, I'm getting this issue every time I'm using LiveCycle designer es4 and was wondering if someone else was getting that and if its fixable. When I design in Designer ES4 and then I press PREVIEW to check my work and then go back into desi
-
Hi, I am doing a workout where in a textarea field, i want to enter the multiple emails followed by the ; sign or say when we enter the CC or BCC field. Problem here is i cannot validate the emails entered in the BCC or CC fields. I want that user en