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

Creating a DOM document with validation?

I have found a nice example of how to create an XML document
using DOM with Java:

http://www.cafeconleche.org/books/xm...s/ch10s03.html

Now, my problem is: When I modify the element type name "desc"
to "slrdesc", the document is still built with the new element
type name "slrdesc". I assume, that the SVG-DTD does not allow
such an element type name "slrdesc" and that therefore the
document created is invalid.

I'd like to have a validating document builder, i.e., in the
very moment, when I am attempting to insert a node that would
make the tree invalid, I want the builder to refuse this
attempt and to report an error, possibly throw an exception or
so. The document of the example above knows its DTD, but it
does not seem to do this validation. Is there a library for
Java to build a DOM (or something like this) with validation
at the momemt an attempt to modify the document is made?
(I would like to use this to create XHTML 1.x documents.)

Or is there at least an explicit call to validate the DOM,
which I have missed?
Jul 20 '05 #1
2 1579


Stefan Ram wrote:
I have found a nice example of how to create an XML document
using DOM with Java:

http://www.cafeconleche.org/books/xm...s/ch10s03.html

Now, my problem is: When I modify the element type name "desc"
to "slrdesc", the document is still built with the new element
type name "slrdesc". I assume, that the SVG-DTD does not allow
such an element type name "slrdesc" and that therefore the
document created is invalid.

I'd like to have a validating document builder, i.e., in the
very moment, when I am attempting to insert a node that would
make the tree invalid, I want the builder to refuse this
attempt and to report an error, possibly throw an exception or
so. The document of the example above knows its DTD, but it
does not seem to do this validation. Is there a library for
Java to build a DOM (or something like this) with validation
at the momemt an attempt to modify the document is made?


DOM Level 3 has a validation module:
http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/
which allows you to manipulate the document with respect to a DTD and/or
schema I think.
I am not sure there are any implementations yet, the implementation report
http://www.w3.org/2003/07/DOM-Level-...entations.html
list Oracle and other as providing implementations.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
Martin Honnen <ma*******@yahoo.de> writes:
DOM Level 3 has a validation module:
http://www.w3.org/TR/2004/REC-DOM-Level-3-Val-20040127/


Here is a method to validate an in-memory DOM. It serializes
the document and reads it back again, doing the validation.

http://cvs.sourceforge.net/viewcvs.p....1&view=markup

OF course, I was looking for something more fine tuned, so
that when an attribute is added to an element, it would just
check whether that attribute might be added to this element
and so.

I thought that something like this was needed whenever a
document is being built and did not expect that it is so
difficult to find.

By the above method, I am supposed to serialize the whole DOM
and read it in again, validating everything again, which seems
to waste processor time.

Jul 20 '05 #3

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

Similar topics

3
by: Kent Tong | last post by:
Hi, This is wha I'm trying to do: <?xml version="1.0"?> <!DOCTYPE library > <library xmlns="http://foo.com"> &foo; </library>
4
by: TP | last post by:
Hi, I have reached a situation where I have to create small pieces of xml (around 8k characters) within my java app. Right now I am using stringbuffer to create the xml which does not go against...
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
24
by: jonathon | last post by:
Hi all, I have a web app with a popup window for entering data. I don't want to access the web every time this window is opened, as most of the app is AJAX. But I can't figure out how to open...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
3
by: Kent Ogletree | last post by:
I am porting a Java XML Validation class over to C# and I am having a problem finding exactly what I need to acomplish the task. First I need to test for well formedness. I know this is usually...
3
by: Christer | last post by:
Hi all! I recently created a MessageBox webcontrol for asp.net. This can be used as is, but I also want to take ude of it in other webcontrols. Right now i creating a ValidationSummary control,...
2
by: Marcin Cenkier | last post by:
Hi, I want to validate a DOM document, and if I build DOM from a stream using documentBuilder.parse() validation using validator.validate(DOMSource) works, but if I create the same document...
1
by: Chris Lieb | last post by:
I have an XML Schema file that I know is correct becuase I currently use it in a VB6 program to validate XML documents. Also, if I load an XML file into VS2005 that is not valid against this...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
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...

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.