473,396 Members | 2,121 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,396 software developers and data experts.

SOS:JAXP1.3 how to capture parent tag details in DOM-schemaValidation


OBJECTIVE---
I need to carry out validation for my XML file against a schema. My XML
contains Multiple record data each having multiple columns in it.
I want to carry out following
1 - validate XML against schema
2- delete the invalid Records from the DOM schema of the XML file
validated
3- get error message generated by Validator for failures
4- get column tag names and data where attributes defines them as
unique for reporting
5 - use the DOM object to do other business operations

#####################
PROBLEM
6--- I am able to carry out 1, 3, and 5 as well
7--- am unable to get solution for 4 - NEED HELP FOR THIS
8--- want to know whether for step 2 there is a better way to delete
the invalid records during validation itself for any validation failure
in its child tag? - NEED HELP FOR THIS

#####################
CODE approach followed SO FAR I S based on
http://java.sun.com/developer/techni...s/xml/jaxp1-3/
which allows DOM to be validated against schema
---
FOR sample xml file
<data>
<record rownum='1'>
<columnA isUNique="Y">data1</columnA>
<columnB>data2</columnB>
</record>
<record rownum='2'>
<columnA isUNique="Y">data3</columnA>
<columnB>data4</columnB>
</record>
<record rownum='3'>
......
</record>
</data>

//SchemaFactory used to compile schema and get a Schema object:
// Load Schema
String language = XMLConstants.W3C_XML_SCHEMA_NS_URI;
SchemaFactory factory = SchemaFactory.newInstance(language);
factory.setErrorHandler(new MySchemaErrorHandler());
//factory.setResourceResolver( new MyLSResourceResolver());
StreamSource ss = new StreamSource(new File("mySchema.xsd")));
Schema schema = factory.newSchema(ss);

// Load XML
File xmlFile = new File("data.xml");
DocumentBuilder parser =
DocumentBuilderFactory.newInstance().newDocumentBu ilder();
document = parser.parse(xmlFile);

// Validate

.......
Validator validator = schema.newValidator();
validator.setErrorHandler( new ErrorHandlerImpl());
DOMResult result = new DOMResult();
validator.validate(new DOMSource(document), result);
/*
//validator.validate(new StreamSource(<XML Document>));
used alternative for validator to validate the instance document or DOM
object in memory, with the augmented result sent to DOMResult.
*/
#####################
Thanks to all in advance

Apr 3 '06 #1
0 976

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

Similar topics

14
by: mich | last post by:
Hi I am trying to use Windbg with SOS.dll on VS 2003 by following the article "SOS:It's Not Just an ABBA Song Anymore" at http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslaye I tried the...
1
by: Chris Cranford | last post by:
I am in the process of implementing a stack machine virtual environment where each entry on the stack is a 32-bit value which then can reference to any memory pointer, numeric value, or alike. ...
0
by: Giovane Calabrese | last post by:
ok. im try to make a multilanguage system based on that tutorial : http://www.123aspx.com/redir.aspx?res=29112 in my aspx pages all text are in labels , and i want to take the name labels...
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
4
by: SOS | last post by:
Hi guys , i create a custom control and place it on a web form, how can i access to this web form from my custom control ? for example i want to add a button to this webform by writing code in...
8
by: Greg Peck | last post by:
Hi I need to update a field (fldX) in one DataTable (dt1) where there is a match on fldA in another DataTable (dt2). Is the only way to do this by itterating through the DataRows of dt1,...
2
by: deejayquai | last post by:
Hi I'm trying to produce a report based on a dynamic crosstab. Ultimately i'd like the report to actually become a sub report within a student end of year record of achievement. The dynamic...
1
by: David Douglass | last post by:
I've been trying to get my hands around the version of SOS that ships with framework 2.0. I wrote a sample app to create the classic deadlock situation. When I run syncblk, I get told which locks...
11
by: aljaber | last post by:
hi, i am facing a problem with my program output here is the program /*********************************************\ * CD Database * * ...
12
by: Charlie | last post by:
I have a file, data.c, where I define all of my global variables. I then have a header file, data.h, which I include in every file in which I reference all of the variables defined in data.c. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.