dtd

The best way to validate XML in a unit test?

醉酒当歌 提交于 2019-12-05 02:32:37
I have a class with a ToString method that produces XML. I want to unit test it to ensure it is producing valid xml. I have a DTD to validate the XML against. Should I include the DTD as a string within the unit test to avoid a dependency on it, or is there a smarter way to do this? If your program validates the XML against the DTD during normal execution, then you should just get the DTD from wherever your program will get it. If not and the DTD is extremely short (only a few lines), then storing it as a string in your code is probably okay. Otherwise, I'd put it in an external file and have

Error: SyntaxError: DOM Exception 12 on Tag Creation Using jQuery

隐身守侯 提交于 2019-12-05 01:33:55
I have the following javascript: var orderItemQuantity = $('<input/>', { type: 'hidden', name: 'order_detail[][quantity]', value: itemQuantity }); The above javascript throws the following error message: Error: SyntaxError: DOM Exception 12 This one works without error: var newListItem = $('<li/>', { html: $('#item_name_'+itemId).text() + '(' + $('#item_quantity_' + itemId).val() +')' + '<a onclick="removeItem(' + itemId + ')">Delete this</a>' + '<input type="hidden" name="order_detail[][item_id]" value="' + itemId + '"/>', id: itemId }); I checked the following question but the answer did not

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

假如想象 提交于 2019-12-05 00:56:54
问题 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

Special Characters in XML

瘦欲@ 提交于 2019-12-05 00:48:10
I am creating a left navigation system utilizing xml and xsl. Everything was been going great until I tried to use a special character in my xml document. I am using » and I get th error. reason: Reference to undefined entity 'raquo'. error code: -1072898046 How do I make this work? You are trying to use an HTML entity in a non-HTML or non-XHTML document. These entities are declared in the document's Document Type Definition (DTD) . You should use the numerical Unicode version of the entity reference . For example, in the case of » you should use » Alternatively, you can define them in your

.NET: Prevent XmlDocument.LoadXml from retrieving DTD

喜夏-厌秋 提交于 2019-12-05 00:06:59
I have following code (C#), it takes too long and it throws exception: new XmlDocument(). LoadXml("<?xml version='1.0' ?><!DOCTYPE note SYSTEM 'http://someserver/dtd'><note></note>"); I understand why it does that. My question is how do I make it stop? I don't care about DTD validation. I suppose I could just regex-replace it, but I am looking for more elegant solution. Background: The actual XML is received from a web site I do not own. When site is undergoing maintenance it returns XML with DOCTYPE that points to the DTD that's not available during maintenance. So my service gets unnecessary

What libraries will parse a DTD using PHP

房东的猫 提交于 2019-12-04 15:55:24
I need to parse DTDs using PHP and am hoping there's a simple library to help out. Each DTD has numerous <!ENTITY... and <!-- Comment... elements, which I need to act upon. Note that I do not need to validate anything against these DTDs, simply parse them as data files themselves. A few options I've looked at: James Clarke's SD , which is an option of last resort, but I'd like to avoid the complexity of building/installing/configuring code external to PHP. I'm not sure it's even possible in my situation. PEAR has an XML_DTD_Parser , which requires installing/configuring PEAR and a number of

The markup declarations contained or pointed to by the document type declaration must be well-formed

左心房为你撑大大i 提交于 2019-12-04 12:54:56
I have this xml document: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE catalog SYSTEM "plantdtd.dtd"> <catalog> <title>Flowers of the week</title> <plant id="A1"> <name>Aloe vera</name> <climate>tropical</climate> <height>60-100cm</height> <usage>medicinal</usage> <image>aloevera.jpg</image> </plant> <plant id="A2"> <name>Orchidaceae</name> <height>8-12in</height> <usage>medicinal</usage> <usage>decoration</usage> <image>Orchidaceae.jpg</image> </plant> </catalog> I wrote a DTD like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE catalog SYSTEM "file:/home/p10398/plantdtd.dtd" [ <

How to define in Liquibase a set of default columns, def. PKs, def. indexes, def. values for table creation?

别等时光非礼了梦想. 提交于 2019-12-04 12:32:43
I just looking around to reduce effort and errors on table creation on liquibase. Is it possible to create a set of default colums for tables? columns: int ID varchar UUID timestamp createdTs timestamp updatedTs int lockVersion constraints ID not NULL and with autogenerated key (as primary key) UUID not NULL createdTS not NULL with default CURRENT_TIMESTAMP updatedTS not NULL with default CURRENT_TIMESTAMP lockVersion not NULL index ID UUID so for example: genericTable.xml <changeSet author="me" id="myCsId"> <column name="id" type="int" /> <column name="uuid" type="varchar(255)" /> <column

Why use both XSD and DTD for XML?

心已入冬 提交于 2019-12-04 12:17:00
Stackoverflow has a couple of great questions contrasting XSD and DTD and choosing between XSD and DTD . But I came across a data format and library that used both XSD and DTD. The XML documents specify the DTD but the supporting library requires the XSD to encode and decode. What are the benefits of using an XSD and DTD at the same time? The most significant time I've seen both DTD and XSD used together relates to the example you cite: A sector standards group had defined their XML vocabulary and grammar long ago using DTD, yet particular consumers of the XML wanted to use tools such as JAXB

Local XML validation with DTD or XSD using a relative path?

故事扮演 提交于 2019-12-04 11:31:47
An XML file can be defined and validated with an Document Type Description (DTD) or XML Schema (xsd) as follows: <?xml version='1.0' encoding='UTF-8'?> <annotation xmlns="http://www.xyz.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.xyz.com file:system.xsd" > or <?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE annotation SYSTEM "http://www.xyz.de/system.dtd"> Both ways define a URL where the DTD or XSD is found. Is there a way to give a relative or local path? So I can store them allong with the XML files instead of relying on a server? It's easy.