473,508 Members | 2,207 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Java, validate XML with XSD, XML not containing "xmlns:xsi=..."

I am using java to validate an XML file with a DTD, without having the
DVD declaration inside the original file, by setting the doctype
dynamically to a transformer like this :

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM, dtd);
transformer.transform(source, new StreamResult(new
StringWriter()));

I would like to know if there is a way to validate an XML file with an
XSD, again, without having the declaration of the xsd file inside the
original XML file, but by declaring it dynamically.

Thank you !
Aug 15 '08 #1
2 3917
killy971 schrieb:
I am using java to validate an XML file with a DTD, without having the
DVD declaration inside the original file, by setting the doctype
dynamically to a transformer like this :

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM, dtd);
transformer.transform(source, new StreamResult(new
StringWriter()));
DTD validation is tightly connected to parsing. So you can parse the
result of the transformation with a validating parser.
I would like to know if there is a way to validate an XML file with an
XSD, again, without having the declaration of the xsd file inside the
original XML file, but by declaring it dynamically.
Have a look at "Chapter 14. Package javax.xml.validation" of "JSR 206
Java™ API for XML Processing (JAXP) 1.3".

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 15 '08 #2
Johannes Koch schrieb:
killy971 schrieb:
>I am using java to validate an XML file with a DTD, without having the
DVD declaration inside the original file, by setting the doctype
dynamically to a transformer like this :

transformer.setOutputProperty(OutputKeys.DOCTYPE_S YSTEM, dtd);
transformer.transform(source, new StreamResult(new
StringWriter()));

DTD validation is tightly connected to parsing. So you can parse the
result of the transformation with a validating parser.
>I would like to know if there is a way to validate an XML file with an
XSD, again, without having the declaration of the xsd file inside the
original XML file, but by declaring it dynamically.

Have a look at "Chapter 14. Package javax.xml.validation" of "JSR 206
Java™ API for XML Processing (JAXP) 1.3".
In this case I'd transform into a DOMResult and then pass the resulting
node to the schema validation.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Aug 15 '08 #3

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

Similar topics

3
10016
by: Mike Dickens | last post by:
hi, i'm sure this has come up before but havn't managed to find an answer. if i have the following xslt <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet method="xml" version="1.0"...
1
2060
by: Zhenya Sigal via .NET 247 | last post by:
I have the following code: XmlElement parent= m_xmlDoc.CreateElement("parent", "http://tempuri.org/myns"); parent.InnerXml = "<child1>text</child1><child2>text</child2>"; ...
3
7124
by: Keith Hill | last post by:
I am creating an XmlDocument in code and then using XmlTextWriter via doc.WriteTo(xwriter) to output the result to a text box. I have a root element that defines a default namespace. However, the...
5
12415
by: NeilL | last post by:
In the XML document I'm trying to create I do the following elem = _doc.CreateElement("Author"); elem.InnerText = "something"; parentElem.AppendChild(elem); Thiw works properly however the...
3
3319
by: Jim Hsu | last post by:
when I use the XmlWebSerivce to response the xmlelement to Web Service client. the ASP.net plumbing work ( the XmlSerializer in WebServices ) will serialize the XML if we can control the wrapper...
3
9881
by: ano | last post by:
Hi, Anyone knows how to get "xmlns" value from XML file? For example, how to check that this xml file has a xmlns or not? Or how to read the xmlns value? <bookstore...
0
1579
by: R. Ian Lee | last post by:
I've built an XSLT file that transforms data to SpreadsheetML format. The XSLT uses a <xsl:call-template/to build each worksheet. For some reason, when I transform the file, it is inserting...
0
1413
by: SolaFide | last post by:
I have an XML doc that looks something like this: <?xml version="1.0" encoding="utf-8"?> <elem1> <elem2 xmlns="http://someurl.com"> <elem3> <item>some stuff here</item> ...
4
17851
markmcgookin
by: markmcgookin | last post by:
Hi, I am creating an MXL doc using XSLT but for some reason it is churning out elements like this <DateTimeLastSaved xmlns="" /> <UserName xmlns="" /> when I delete xmlns="" it works fine,...
0
7231
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
7336
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,...
0
7401
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...
1
7063
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
7504
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
3211
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...
0
3196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1568
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
432
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.