Hello mate,

It generates the same error: ERROR #6301: SAX XML Parser Error: invalid character 0x18 while processing Anonymous Stream at line 1 offset 4183

Here is the code:

msg.Value.Rewind()
set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="D:\DATABASES\OVPATH\temp\test0.xml"
set fs.TranslateTable = "UTF8"
set tSC=fs.CopyFrom(msg.Value)
set tSC=fs.%Save()

reader=##class(%XML.Reader).%New()
fs.Rewind() // might not be necessary, but won't hurt
Set sc = reader.OpenStream(fs)

if $$$ISERR(sc)
{
set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="D:\DATABASES\OVPATH\temp\errorOpen0.xml"
do fs.Write($$$StatusDisplayString(sc))
set tSC=fs.%Save()
}

John,

Just to let you know, I am still a beginner with ObjectScript/Cache/Healthsare, so please excuseany primary mistakes you may encounter :)

Can you kindly help me out to write this piece of code you advised? (P.S: msg.Value is the stream)

set fs=##class(%Library.GlobalCharacterStream).%New()
set fs.TranslateTable = "UTF8"
set tSC=fs.CopyFromAndSave(msg.Value)

  sc= xread.OpenStream(???)

if $$$ISERR(sc)
{
...
}

---

I came up with that a few moments ago: (at this point I have the stream available (msg.Value) and I will handle it in 2 different ways: by writing is a file and trying to open it (OpenFile) and by reading it (OpenStream))

  //
  // 1st approach - it succeeds, so the file errorOpenFile.xml is NOT generated
  //    
  d msg.Value.Rewind()
  set fs=##class(%Stream.FileCharacter).%New()
  set fs.Filename="D:\DATABASES\OVPATH\temp\test.xml"
  set fs.TranslateTable = "UTF8"
  set tSC=fs.CopyFrom(msg.Value)
  set tSC=fs.%Save()
    
  s reader=##class(%XML.Reader).%New()
  Set sc = reader.OpenFile("temp/test.xml")
    
  if $$$ISERR(sc)
  {
    set fs=##class(%Stream.FileCharacter).%New()
    set fs.Filename="D:\DATABASES\OVPATH\temp\errorOpenFile.xml"
    do fs.Write($$$StatusDisplayString(as))
    set tSC=fs.%Save()
  }    

  //
  // 2nd approach - it fails, so I have the file errorOpenStream.xml generated
  //    
  Set xread = ##class(%XML.Reader).%New()
  Set xread.IgnoreNull=1                  
  d msg.Value.Rewind()    
  s sc= xread.OpenStream(msg.Value)
    
  if $$$ISERR(sc)
  {
    set fs=##class(%Stream.FileCharacter).%New()
    set fs.Filename="D:\DATABASES\OVPATH\temp\errorOpenStream.xml"
    do fs.Write($$$StatusDisplayString(sc))
    set tSC=fs.%Save()
  }

Hello mate,

Thanks for you quick response. Actually there was no specific reason for using the FileBinary, so I managed to change it to FileCharacter and used also the property "TranslateTable = "UTF8", which hence allowed the file to be written with the special character I wanted.

By discovering that, I came back to the 1st place I originally thought the issue would be and now I guess that it's the right place to look at:

Method OnProcessInput(pInput As %Stream, Output pOutput As %RegisteredObject, ByRef pHint As %String) As %Status
{
    // Create an instance of %XML.Reader
    Set xread = ##class(%XML.Reader).%New()
    Set xread.IgnoreNull=1
        
    // Begin processing of the file
    pInput.Rewind()
    
    sc= xread.OpenStream(pInput)
   
     if $$$ISERR(sc)
{
set fs=##class(%Stream.FileCharacter).%New()
set fs.Filename="c:\TEMP\OnProcessInput00.xml"
set fs.TranslateTable = "UTF8"
do fs.Write($$$StatusDisplayString(sc))
set tSC=fs.%Save()
}

---

Here I had the file created and the error message written in it (ERROR #6301: SAX XML Parser Error: invalid character 0x18 while processing Anonymous Stream at line 1 offset 4627).

So I presume that
sc= xread.OpenStream(pInput)

Is erroring, because the stream contains a special character.

What do you think?

Thanks

Hey John, thanks for you response!

I wrote some debug piece of code to write into a xml file the pInput content and that's what I get:

<?xml version="1.0" encoding="UTF-8" ?> ... <Value><![CDATA[ ... <P>SORRY TO SAY THAT THIS CHARACTER WILL MESS THIS UP  ?</P> ... ]]></Value>

Where you see the question mark, it is indeed the place the weird character is supposed to be.

By opening the file with Notepad++ and checking the 'Encoding' menu, it shows 'Encode with UTF-8 without BOM'.

Any clues?

Thanks

My team leader advised me to do one thing that did the trick: stop the production, save the business rule and then restart the production and resend the message again.

He said it sounds like it's something related to memory management done by the Ensemble, because for safety reasons/keep the messages flowing correctly, it keeps some previous compiled version in memory until a certain point and then brings new one as soon as it realizes that either it's the right time to do it or I've ordered it to do so. I might be saying bullshit, but as I've said, I'm just a begginer in this environment.

Thanks mates!

My team leader advised me to do one thing that did the trick: stop the production, save the business rule and then restart the production and resend the message again.

He said it sounds like it's something related to memory management done by the Ensemble, because for safety reasons/keep the messages flowing correctly, it keeps some previous compiled version in memory until a certain point and then brings new one as soon as it realizes that either it's the right time to do it or I've ordered it to do so. I might be saying bullshit, but as I've said, I'm just a begginer in this environment.

Thanks mates!

My team leader advised me to do one thing that did the trick: stop the production, save the business rule and then restart the production and resend the message again.

He said it sounds like it's something related to memory management done by the Ensemble, because for safety reasons/keep the messages flowing correctly, it keeps some previous compiled version in memory until a certain point and then brings new one as soon as it realizes that either it's the right time to do it or I've ordered it to do so. I might be saying bullshit, but as I've said, I'm just a begginer in this environment.

Thanks mates!

My team leader advised me to do one thing that did the trick: stop the production, save the business rule and then restart the production and resend the message again.

He said it sounds like it's something related to memory management done by the Ensemble, because for safety reasons/keep the messages flowing correctly, it keeps some previous compiled version in memory until a certain point and then brings new one as soon as it realizes that either it's the right time to do it or I've ordered it to do so. I might be saying bullshit, but as I've said, I'm just a begginer in this environment.

Thanks mates!

Hello mate,

Thanks for the response. Actually I'm using Healthshare, sorry for the wrong information. I'm quite new on that.

The idea about testing each of them individually does not work. It seems that any constraint that I add there, it blocks the operations below it. If I remove the constraint, it goes through well.

Again, as I've said in my first comment, the rule that I have which has no constraints, works pretty fine.

But the thing is I need to add this constraint in order to assess a few data from the HL7 ADT A01 message and that is the only way to do it, right?

Healthshare version: 2015.2 1HS. 7913.0

Hello Daniel,

Thanks for you help , but it doesn't help me much. As I said, if I place a very basic rule there with (if 1=1 OR 1=2), it works fine, but as soon as I just place a constraint on the rule (which source is a hl7 file being sent by my business service 'Service for input file'), it blocks the message from being forwarded.

Here is the rule:

<ruleSet name="Rule set name =)" effectiveBegin="" effectiveEnd="">
<rule name="" disabled="false">
<constraint name="source" value="Service for input file"></constraint>
<constraint name="docCategory" value="2.2"></constraint>
<constraint name="docName" value="ADT_A01"></constraint>
<when condition="(1=2)||(1=1)">
<send transform="" target="BO HL7"></send>
</when>
</rule>