Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » How to validate XML files without specifying xmlns namespace attribute in the root element?((Eclipse WTP) XML Catalog entries are used to associate an XML Schema with a given namespace key. Can I do the same without adding xmlns namespace to every XML file?)
icon12.gif  How to validate XML files without specifying xmlns namespace attribute in the root element? [message #675080] Mon, 30 May 2011 08:51 Go to next message
xemox  is currently offline xemox
Messages: 9
Registered: May 2010
Junior Member
We have a lot of projects that consists of XML files. We have to validate all these XML files based on a single XML schema.

In order to realize this, we have used XML Catalog entries to associate an XML Schema with a given namespace key. In this way you define the location of XML Schema only once in XML Catalog and all XML files will be validated based on this single XML Schema. You can see the XML Category Entry below:

Entry element: URI
Location: dm_d/src/DESchema.xsd
URI: platform:/resource/dm_d/src/DESchema.xsd
Key type: Namespace name
Key: http://www.example.com

This method works fine, BUT only thing that you have to do is to add 'xmlns' namespace attribute to root element of every single XML file in your projects.

We don't want to add the namespace attribute to each XML file, because we have to update a lot of Client projects, which is not efficient and feasible.

At the moment, we are looking for other ways of XML validation based on a single XML schema without introducing xmlns namespace to each XML file.

How can we do this in Eclipse IDE?

Normal XML Validation (e.g.: underlines when you have wrong closing tag,..) in Eclipse XML editor works without namespace. Here, you don't have to define anything that relates to XML Schema. How it is done for this normal XML validation?

Can we do the same as in the normal XML validation?

Any tips, guidance in this direction are very appreciated.

Thanks! Smile

Regards,
Xemox.







(no subject) [message #675221 is a reply to message #675080] Mon, 30 May 2011 16:27 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Does your schema have a target namespace? If so, your root element must
be using that namespace to conform to it, rigth?

xemox wrote:
> We have a lot of projects that consists of XML files. We have to
> validate all these XML files based on a single XML schema.
> In order to realize this, we have used XML Catalog entries to
> associate an XML Schema with a given namespace key. In this way you
> define the location of XML Schema only once in XML Catalog and all XML
> files will be validated based on this single XML Schema. You can see
> the XML Category Entry below:
>
> Entry element: URI
> Location: dm_d/src/DESchema.xsd
> URI: platform:/resource/dm_d/src/DESchema.xsd
> Key type: Namespace name
> Key: http://www.example.com
>
> This method works fine, BUT only thing that you have to do is to add
> 'xmlns' namespace attribute to root element of every single XML file
> in your projects.
>
> We don't want to add the namespace attribute to each XML file, because
> we have to update a lot of Client projects, which is not efficient and
> feasible.
>
> At the moment, we are looking for other ways of XML validation based
> on a single XML schema without introducing xmlns namespace to each XML
> file.
>
> How can we do this in Eclipse IDE?
>
> Normal XML Validation (e.g.: underlines when you have wrong closing
> tag,..) in Eclipse XML editor works without namespace. Here, you don't
> have to define anything that relates to XML Schema. How it is done
> for this normal XML validation?
>
> Can we do the same as in the normal XML validation?
>
> Any tips, guidance in this direction are very appreciated.
>
> Thanks! :)
>
> Regards,
> Xemox.
>
>
>
>
>
>
>
>
(no subject) [message #675242 is a reply to message #675080] Mon, 30 May 2011 21:23 Go to previous messageGo to next message
Stanimir Stamenkov is currently offline Stanimir Stamenkov
Messages: 254
Registered: July 2009
Senior Member
Mon, 30 May 2011 04:51:02 -0400, /xemox/:

> At the moment, we are looking for other ways of XML validation based
> on a single XML schema without introducing xmlns namespace to each
> XML file.
>
> How can we do this in Eclipse IDE?

I don't think so. I've asked about 4 years ago about similar (if
not the same) thing:

"Infer an XML Schema or DTD grammar depending on the root element
name" <http://www.eclipse.org/forums/index.php/mv/msg/63174/>

I haven't seen development on the front, at least not in the base
Eclipse bundles.

--
Stanimir
Re: (no subject) [message #675263 is a reply to message #675221] Tue, 31 May 2011 00:21 Go to previous messageGo to next message
xemox  is currently offline xemox
Messages: 9
Registered: May 2010
Junior Member
Yes, my schema has a target namespace, namely http://www.example.com (as described above). When I add this namespace to my XML file, it works fine, it validates.

BUT the problem is that I don't want to add namespace to root element. Because it is not feasible to update all XML files/projects that are already in the client/customer side.

Do you know how to validate XML file based on XML Schema without introducing namespaces?

It is somehow done, in normal XML editor, it underlines with red color when you have non-valid XML. Where is that Schema? It/namespace is NOT in the ROOT element.

How can we do that?

[Updated on: Fri, 03 June 2011 08:06]

Report message to a moderator

Re: (no subject) [message #675277 is a reply to message #675263] Tue, 31 May 2011 01:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26141
Registered: July 2009
Senior Member
Comments below.

xemox wrote:
> Yes, my schema has a target namespace, namely http://www.example.com
> (as described above). When I add this namespace to my XML file, it
> works fine, it validates.
Yes because for an instance to conform to a schema it must use the
namespace of the schema on the root element.
>
> BUT the problem is that I don't want to add namespace to root element.
> Because it is not feasible to update all XML files/projects that are
> already in the client/customer side.
Then you should be using a schema without a namespace.
>
> Do you know how to validate XML file based on XML Schema without
> introducing namespaces?
A root element without a namespace is describe by a schema without a
targetNamespace.
>
> It is somehow done, in normal XML editor, it underlines with red color
> when you have non-valid XML. Where is that Schema? It/namespace is NOT
> in the ROOT element.
It might be hard to have multiple schemas without a target namespace
(see other comment in this thread) but hopefully there's at least
support for one schema without a target namespace.
>
> How an we do that?
(no subject) [message #675640 is a reply to message #675080] Wed, 01 June 2011 04:38 Go to previous messageGo to next message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2310
Registered: July 2009
Senior Member
On 5/30/2011 4:51 AM, xemox wrote:
> We have a lot of projects that consists of XML files. We have to
> validate all these XML files based on a single XML schema.
> In order to realize this, we have used XML Catalog entries to associate
> an XML Schema with a given namespace key. In this way you define the
> location of XML Schema only once in XML Catalog and all XML files will
> be validated based on this single XML Schema. You can see the XML
> Category Entry below:
>
> Entry element: URI
> Location: dm_d/src/DESchema.xsd
> URI: platform:/resource/dm_d/src/DESchema.xsd
> Key type: Namespace name
> Key: http://www.example.com
>
> This method works fine, BUT only thing that you have to do is to add
> 'xmlns' namespace attribute to root element of every single XML file in
> your projects.
>
> We don't want to add the namespace attribute to each XML file, because
> we have to update a lot of Client projects, which is not efficient and
> feasible.
>
> At the moment, we are looking for other ways of XML validation based on
> a single XML schema without introducing xmlns namespace to each XML file.
>
> How can we do this in Eclipse IDE?
>
> Normal XML Validation (e.g.: underlines when you have wrong closing
> tag,..) in Eclipse XML editor works without namespace. Here, you don't
> have to define anything that relates to XML Schema. How it is done for
> this normal XML validation?
>
> Can we do the same as in the normal XML validation?

Bug 206370 is a relevant read, but the short answer is no, not without
writing plug-ins to deal with your special case, and maybe not even
then. They're not *.xml files at least, right?

https://bugs.eclipse.org/bugs/show_bug.cgi?id=206370

--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Re: (no subject) [message #676040 is a reply to message #675263] Thu, 02 June 2011 15:14 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick Sandonato
Messages: 126
Registered: July 2009
Senior Member
xemox wrote on Mon, 30 May 2011 20:21
Yes, my schema has a target namespace, namely http://www.example.com (as described above). When I add this namespace to my XML file, it works fine, it validates.

BUT the problem is that I don't want to add namespace to root element. Because it is not feasible to update all XML files/projects that are already in the client/customer side.

Do you know how to validate XML file based on XML Schema without introducing namespaces?

It is somehow done, in normal XML editor, it underlines with red color when you have non-valid XML. Where is that Schema? It/namespace is NOT in the ROOT element.

How an we do that?


There was an extension point added by https://bugs.eclipse.org/341279 that allows one to associate schemas without requiring explicit reference of the schema in the XML document. If you're willing to implement it, this might help you.
Re: (no subject) [message #676212 is a reply to message #675640] Fri, 03 June 2011 08:21 Go to previous messageGo to next message
xemox  is currently offline xemox
Messages: 9
Registered: May 2010
Junior Member
Quote:
Bug 206370 is a relevant read, but the short answer is no, not without
writing plug-ins to deal with your special case, and maybe not even
then. They're not *.xml files at least, right?


They are 'XML' files with javascript embedded in some xml tags with <![CDATA[ .. ]]>.
But the structure of all XML files confirms all XML rules(properly nested tags, closing tags...). JS code is always inside <![CDATA[ .. ]]>. SO, they are valid XML files.
Re: (no subject) [message #677217 is a reply to message #676212] Tue, 07 June 2011 20:44 Go to previous message
Nitin Dahyabhai is currently offline Nitin Dahyabhai
Messages: 2310
Registered: July 2009
Senior Member
On 6/3/2011 4:21 AM, xemox wrote:
> Quote:
>> Bug 206370 is a relevant read, but the short answer is no, not without
>> writing plug-ins to deal with your special case, and maybe not even
>> then. They're not *.xml files at least, right?

I actually meant in terms of their file names. You have considerably
more flexibility if your file names can be used to differentiate them.

--
Nitin Dahyabhai
Eclipse WTP Source Editing and JSDT
IBM Rational


---
Nitin Dahyabhai
Eclipse WTP, IBM
Previous Topic:New Editor?
Next Topic:Extending the HTML Editor
Goto Forum:
  


Current Time: Sat Oct 25 04:30:34 GMT 2014

Powered by FUDForum. Page generated in 0.03761 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software