web stats
TypeError: A DOCTYPE is not allowed in content. - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 12-09-2015, 08:57 AM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 296
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default TypeError: A DOCTYPE is not allowed in content.

MC 3.3
Java 1.7
Windows 10

How to process this message?
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE SpiroXML1 [
<!ELEMENT SpiroXML1 (E)*>
<!ELEMENT E (E)*>
<!ATTLIST E T CDATA #REQUIRED N CDATA #IMPLIED V CDATA #IMPLIED >]>
<SpiroXML1>
Always get the DOCTYPE error
__________________
X Connections
https://documentor.email
https://www.x-connections.com
Reply With Quote
  #2  
Old 12-09-2015, 09:43 AM
jadams4's Avatar
jadams4 jadams4 is offline
OBX.3 Kenobi
 
Join Date: Aug 2015
Posts: 143
jadams4 is on a distinguished road
Default

what is the use case?

it looks like someone had a similar problem before:
http://www.mirthcorp.com/community/f...hlight=doctype

You could remove the <!DOCTYPE line, save it to a variable and then place it back in the message before sending it to the destinations.

Hope this helps some!
Reply With Quote
  #3  
Old 12-09-2015, 09:53 AM
narupley's Avatar
narupley narupley is offline
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,124
narupley is on a distinguished road
Default

Yep that's basically what you should do. Although DTDs are valid for XML, E4X doesn't support them. So you could just set your data types to Raw and your transformer will run, but then you can't access XML nodes using E4X.

One option is to use the preprocessor to extract that prolog and put it in the channel map:

Code:
var pattern = $gc('pattern');
if (!pattern) {
	pattern = java.util.regex.Pattern.compile('^(\\s*(<\\?xml.*\\?>)?\\s*(<!DOCTYPE[^\\[>]*(\\[\\s*(<![^>]*>\\s*)*\\])?[^>]*>)?\\s*)');
	$gc('pattern', pattern);
}

var prolog = '';
var matcher = pattern.matcher(message);
if (matcher.find()) {
	prolog = matcher.group(1);
	message = message.substring(0, matcher.start(1)) + message.substring(matcher.end(1));
}
$c('prolog', prolog);
return message;
Then in your destination template instead of just the encoded data, include the prolog too:

Code:
${prolog}${message.encodedData}
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #4  
Old 12-09-2015, 01:32 PM
mdehoog mdehoog is offline
Mirth Guru
 
Join Date: Mar 2011
Location: Apeldoorn the Netherlands
Posts: 296
mdehoog is on a distinguished road
Send a message via Skype™ to mdehoog
Default

Whooo. Thanks. This is it.

Now I will figure out how your code works
__________________
X Connections
https://documentor.email
https://www.x-connections.com
Reply With Quote
  #5  
Old 09-19-2017, 02:56 AM
vibinChander vibinChander is offline
OBX.2 Kenobi
 
Join Date: Jul 2015
Location: Chennai
Posts: 75
vibinChander is on a distinguished road
Send a message via Skype™ to vibinChander
Default how can this be achieved in response tab

Im receiving a DOCTYPE as a HTML response. We are concerned about deployment so we are not going for Jsoup html parser. In this case how can we achieve this?. I basically want to remove DOCTYPE and fetch the response content.

Using JSOUP its working fine as provided below.

Code:
importPackage(org.jsoup);
var doc = Jsoup.parse(msg);
var tds = doc.getElementsByTag("h2");
var text = tds.text();
var responseStatusValue = text.substring(0,3);
if(responseStatusValue=='401')
{
	logger.debug("Data : "+ text.substring(0,3));	
	router.routeMessage('TEST - client', '');	
}
I tried making the response type as RAW and built the below code:

Code:
var updateMsg= new XML (msg).replace('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">','')
var newMsg= new XML (updateMsg);
logger.debug('XML : '+newMsg);
var responseData = newMsg['head']['title'].toString(); 
logger.debug(newMsg['head']['title'])
var responseDataStatus = responseData.substring(0,3);
but the code var
HTML Code:
 responseData = newMsg['head']['title'].toString();
is not returning anything.

Is there a way to overcome this issue?
__________________

Mirth Interface Engineer
AWS DevOps

Last edited by vibinChander; 09-19-2017 at 03:03 AM. Reason: not well formatted
Reply With Quote
  #6  
Old 09-19-2017, 04:02 AM
siddharth siddharth is offline
Mirth Guru
 
Join Date: Feb 2013
Posts: 835
siddharth is on a distinguished road
Default

What problem you facing while implementing the solution given by Nick, in post above?
__________________
HL7v2.7 Certified Control Specialist!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 11:42 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Mirth Corporation