Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XML did not validate when bounded DTD file was not found #167

Closed
c600g opened this issue Jul 12, 2019 · 14 comments
Closed

XML did not validate when bounded DTD file was not found #167

c600g opened this issue Jul 12, 2019 · 14 comments
Assignees
Labels
bug Something isn't working DTD validation
Milestone

Comments

@c600g
Copy link

c600g commented Jul 12, 2019

If I load an XML file with a specified DTD such as the following:

<?xml version="1.0" standalone="no" ?>
<!DOCTYPE inEQUAL_PMT SYSTEM "inEQUAL_PMT.dtd">
<inEQUAL_PMT>

   <!-- Basic Input -->
   <LoanDate>2019-01-01</LoanDate>
   <PmtDate>2019-02-01</PmtDate>
   <IntRate>10</IntRate>
   
   <!-- The Proceeds and Term -->
   <Proceeds>10000.00</Proceed>
   <Term>36</Term>
   
</inEQUAL_PMT>

If the extension can not find the DTD, then I understand why no validation can be done. However, it also does not check for well-formedness (e.g. non-matching closing tags), which I would expect the extension to fall back upon.

@fbricon fbricon added the bug Something isn't working label Jul 12, 2019
@fbricon
Copy link
Collaborator

fbricon commented Jul 12, 2019

agreed, seems like the reasonable thing to do.

@c600g
Copy link
Author

c600g commented Jul 12, 2019

Also, is there any way to specify a DTD search path? Our application accepts XML messages and manages the DTD path internally, so absolute DTD paths are not possible nor portable.

@fbricon
Copy link
Collaborator

fbricon commented Jul 12, 2019

file associations work for XSDs, but not for DTD apparently. cc @angelozerr

@angelozerr
Copy link
Contributor

However, it also does not check for well-formedness (e.g. non-matching closing tags), which I would expect the extension to fall back upon.

I agree that it should work like this, but problem comes from Xerces (the java library which manage validation) which throw an exception (IOException) when DTD is not found instead of reporting this problem as error. Throwing an exception stops in this case validation. Other XML editors like WTP XML Editor from Eclipse has this problem. To fix this problem, we must find a solution to catch the IOEception, report it as an error, not re-throw the error to continue the validation.

file associations work for XSDs, but not for DTD apparently

Indeed, it's a Xerces limitation. To manage file association for XSD, we use
http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation property to set XML Schema to use. I have not found the similar property for DTD.

@c600g even if LSP4XML supports DTD, the DTD support must be improved again. Indeed we focus our work on XSD because today we consider that XSD is more used than DTD. But if we have a lot of user feedbacks which need DTD, we could see if we will spend more time to support DTD.

@angelozerr
Copy link
Contributor

Also, is there any way to specify a DTD search path? Our application accepts XML messages and manages the DTD path internally, so absolute DTD paths are not possible nor portable.

What about using XML catalog? Could you please add a sample of DTD and a XML file that you wish to manage ?

@c600g
Copy link
Author

c600g commented Jul 16, 2019

@angelozerr I have attached a zip archive containing a sample DTD and XML request which validates against that DTD to this comment.

sample.zip

@angelozerr
Copy link
Contributor

Thanks @c600g! Ok if I understand your requirement you have a XML which declares a DTD:

<!DOCTYPE inEQUAL_PMT SYSTEM "inEQUAL_PMT.dtd">
<inEQUAL_PMT>

and your main problem is that it doesn't work in vscode. Is that? If it that you must write a XML catalog and configure vscode to use it.

If you don't know how to write a XML catalog and configure settings in vscode please see this issue #87 You will find a sample of catalog.

Please give us feedback if it works fr you.

If the extension can not find the DTD, then I understand why no validation can be done. However, it also does not check for well-formedness (e.g. non-matching closing tags), which I would expect the extension to fall back upon.

I'm working on this issue.

@c600g
Copy link
Author

c600g commented Jul 16, 2019

Thanks very much for the tip @angelozerr. I've never worked with XML catalogs in the past, but after a bit of research on the subject, I think I have it working as expected.

Here is the catalog.xml file I am using which works for me now:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN" "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" prefer="system">
  <system systemId="inEQUAL_PMT.dtd" uri="file:///home/alank/work/sce/Compile/32/xml/inEQUAL_PMT.dtd" />
  <rewriteSystem systemIdStartString="in" rewritePrefix="file:///home/.../xml/in" />
  <rewriteSystem systemIdStartString="out" rewritePrefix="file:///home/.../xml/Output/out" />
</catalog>

@c600g
Copy link
Author

c600g commented Jul 16, 2019

Is there any way to specify a different XML catalog file for different operating systems? I mostly work on Linux but will occasionally need to do some work on a Windows 10 machine. This would require a different catalog.xml file using Windows paths.

angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Jul 16, 2019
@c600g
Copy link
Author

c600g commented Jul 16, 2019

In response to my comment above, it looks as if the VS Code team is working on os and platform specific qualifiers in the settings.json file, which will hopefully resolve the issue in the near future.

angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Jul 16, 2019
angelozerr added a commit to eclipse-lemminx/lemminx that referenced this issue Jul 16, 2019
@angelozerr
Copy link
Contributor

angelozerr commented Jul 16, 2019

but after a bit of research on the subject, I think I have it working as expected.

Great!

Is there any way to specify a different XML catalog file for different operating systems?

To be honnest with you, I'm not an expert with XML catalog. Please try it and give us feedback. XML catalog is very used in the XML words.

In response to my comment above, it looks as if the VS Code team is working on os and platform specific qualifiers in the settings.json file, which will hopefully resolve the issue in the near future.

Sorry I don't understand what you mean?

Here a demo with my current work:

DTDInvalidDemo

@c600g
Copy link
Author

c600g commented Jul 16, 2019

@angelozerr I am hoping that the VS Code developers will implement OS and/or hostname qualifiers for the settings.json file, so that I could then specify a different catalog.xml file for Windows vs. Linux. See this issue for what I am talking about.

The plugin works fine for me on my Linux box now with the addition of the catalog.xml file. Thanks for all of your assistance!

@angelozerr
Copy link
Contributor

See this issue for what I am talking about.

Thank's for the information.

The plugin works fine for me on my Linux box now with the addition of the catalog.xml file. Thanks for all of your assistance!

You are welcome! The DTD validation when DTD doesn't exists will come soon.

fbricon pushed a commit to eclipse-lemminx/lemminx that referenced this issue Jul 17, 2019
@angelozerr angelozerr added this to the 0.8.0 milestone Jul 17, 2019
@angelozerr
Copy link
Contributor

Fixed with eclipse-lemminx/lemminx#512 This feature will be available in 0.8.0

@angelozerr angelozerr changed the title When DTD is not found, XML is not checked for well-formedness XML did not validate when bounded DTD file was not found Jul 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working DTD validation
Projects
None yet
Development

No branches or pull requests

3 participants