Announcement

Collapse
No announcement yet.

TypeError: A DOCTYPE is not allowed in content.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #2
    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!

    Comment


    • #3
      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.

      Comment


      • #4
        Whooo. Thanks. This is it.

        Now I will figure out how your code works
        X Connections
        https://documentor.email
        https://www.x-connections.com

        Comment


        • #5
          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?
          Last edited by vibinChander; 09-19-2017, 02:03 AM. Reason: not well formatted

          Mirth Interface Engineer
          AWS DevOps

          Comment


          • #6
            What problem you facing while implementing the solution given by Nick, in post above?
            HL7v2.7 Certified Control Specialist!

            Comment

            Working...
            X