dtd

xmltask confused about dtd

血红的双手。 提交于 2019-12-04 10:04:07
I'm trying to use xmltask for ant to modify a file in a subdirectory: project/path/to/file.xml The file refers to a DTD like this: <!DOCTYPE data SYSTEM "mydtd.dtd"> I don't have the flexibility to change these documents. This DTD is stored in the same subdirectory, which has always worked fine: project/path/to/mydtd.dtd Unfortunately, xmltask is trying to locate the dtd in my project's top-level directory, which is where my build file is located, and where I run from: [xmltask] java.io.FileNotFoundException: /home/me/project/mydtd.dtd (The system cannot find the file specified) I see in the

Scope of XML languages defined by DTD vs XSD

半世苍凉 提交于 2019-12-04 09:41:14
Does the following propositions hold: For every DTD there is an XSD that defines exactly the same language, and for every XSD there is a DTD that defines exactly the same language. Or put another way: The collection of languages defined by any DTD is exactly the the collection of languages defined by any XSD? Expanding on the question a little: An XML document is basically a large string. A language is a collection of strings. For example, the (infinite) set of all MathML documents is a language, and so is the set of all RSS documents and so on. MathML (RSS, ...) is also a proper subset of the

Validate xml via dtd, different directory for dtd

筅森魡賤 提交于 2019-12-04 09:03:11
I am trying to validate an xml file via a .dtd. I have write this validator: public bool Validation(XmlDocument xmlDoc) { var xml = XmldocToString(xmlDoc); var r = new XmlTextReader(new StringReader(xml)); var settings = new XmlReaderSettings(); var sb = new StringBuilder(); settings.ProhibitDtd = false; settings.ValidationType = ValidationType.DTD; settings.ValidationEventHandler += (a, e) => { sb.AppendLine(e.Message); _isValid = false; }; XmlReader validator = XmlReader.Create(r, settings); while (validator.Read()) { } validator.Close(); return _isValid; } The problem is that I must have

Create DTD for node with inner xml node and text

亡梦爱人 提交于 2019-12-04 05:15:50
问题 I have pretty simple XML shown below. <?xml version="1.0" ?> <message> This is a message with some <bold>highlights</bold> in a text. </message> How can I create DTD to validate things inside message element? A mixture of node and text. This does not work. <!DOCTYPE message [ <!ELEMENT message (#PCDATA, bold)> <!ELEMENT bold (#PCDATA)> ]> 回答1: When you have mixed content (both elements and text), you can't specify order (use | instead of , ) and it has to be zero or more occurrences ( * ).

Referring to a local DTD in Java

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 02:35:41
I have some XML that I'm parsing with a SAX parser in Java. It starts with this preamble: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "http://www.w3.org/Math/DTD/mathml3/mathml3.dtd"> How do I change this to use a local DTD? I suppose I could do something like this: <!DOCTYPE math PUBLIC "-//W3C//DTD MathML 3.0//EN" "file:///c:/MathML/mathml3.dtd"> Not exactly like that, but something like that. However, I need the path to be independent of the user's system. How do I use a local DTD with a path relative to the class path? Take a look at this article on using XML catalogs to resolve

Where can I find itext.dtd?

a 夏天 提交于 2019-12-04 02:32:15
问题 We were using http://www.ujihara.jp/iTextdotNET/itext.dtd as our DOCTYPE in all our XML files which is actually a bad practice. We did not know it until our PDF generations failed since the site went down for some reason. Any suggestions on where I could find the same dtd file? We would need to download and locally host it. Tried Google search caches, but could not find the dtd file. 回答1: OK, I've gone through my archives (you gave me quite some work) and I found a version of the itext.dtd I

.NET : How to validate XML file with DTD without DOCTYPE declaration

六眼飞鱼酱① 提交于 2019-12-04 00:55:38
问题 I have an XML file with no DOCTYPE declaration that I would like to validate with an external DTD upon reading. Dim x_set As Xml.XmlReaderSettings = New Xml.XmlReaderSettings() x_set.XmlResolver = Nothing x_set.CheckCharacters = False x_set.ProhibitDtd = False x = XmlTextReader.Create(sChemin, x_set) How do you set the path for that external DTD? How do you validate? 回答1: I have used the following function successfully before, which should be easy to adapt. How ever this relies on creating a

Error parsing a DTD using lxml

て烟熏妆下的殇ゞ 提交于 2019-12-03 21:11:21
I'm trying to write a validation script that will validate XML against the NITF DTD, http://www.iptc.org/std/NITF/3.4/specification/dtd/nitf-3-4.dtd . Based on this post I came up with the following simple script to validate a NITF XML document. Bellow is the error message I get when the script is run, which isn't very descriptive and makes it hard to debug. Any help is appreciated. #!/usr/bin/env python def main(): from lxml import etree, objectify from StringIO import StringIO f = open('nitf_test.xml') xml_doc = f.read() f.close() f = open('nitf-3-4.dtd') dtd_doc = f.read() f.close() dtd =

Validate XML using a custom DTD in PHP

*爱你&永不变心* 提交于 2019-12-03 19:54:14
问题 Is there a way (without installing any libraries) of validating XML using a custom DTD in PHP? 回答1: Take a look at PHP's DOM, especially DOMDocument::schemaValidate and DOMDocument::validate. The example for DOMDocument::validate is fairly simple: <?php $dom = new DOMDocument; $dom->Load('book.xml'); if ($dom->validate()) { echo "This document is valid!\n"; } ?> 回答2: If you have the dtd in a string, you can validate against it by using a data wrapper for the dtd: $xml = '<?xml version="1.0"?>

Struts2 & Tiles: When apache.org is down my webapp fails to start

匆匆过客 提交于 2019-12-03 17:23:42
I am building a Struts2 web application which uses tiles however I have discovered a quite frustrating problem where if apache.org is down (which seems to happen quite regularly) the web application fails to start. This is because in its standard setup the StrutsTilesListener tries to load the tiles defenitions file which includes a DOCTYPE with a public-id which points to a DTD located on tiles.apache.org. When the application starts up the definition file is loaded using Apache Xerces via Apache Commons Digester which tries to load the DTD from tiles.apache.org but if apache.org is down then