Here's the code I ran:

Class User.XMLTest
{

/// do ##class(User.XMLTest).Test()
ClassMethod Test()
{
    set source = ..GetXData("Source")
    set xslt = ..GetXData("XSLT")
    #dim result As %Stream.Object
    set sc = ##class(%XML.XSLT.Transformer).TransformStream(source, xslt, .result)
    
    do result.OutputToDevice()
}

ClassMethod GetXData(name) As %Stream.TmpCharacter [ CodeMode = expression ]
{
##class(%Dictionary.XDataDefinition).IDKEYOpen($classname(), name).Data
}

XData Source
{
Your Message
}

XData XSLT
{
Your XSLT
}

}

and here's the result:

{
"Message" :
{
"Header" :
{
"Code" : "HOT",
"Date" : "2017-12-08 11:22:34.658"
}, "Body" : [
 
{
"Code" : "HOT",
"Name" : "SIDE",
"Type" : "AADULT",
"Sec" : "MSec",
"ardge" : "Adult",
"Nder" : "F",
"TBC" : "21",
"BO" : "14",
"DBOC" : "0",
"LBC" : "5",
"AB" : "2"
},

...

Check %objlasterror and also check your XML encoding, there may be problems if your encoding does not match declaration.

But how about getting not just a progress but how to get some data before task finished. 

Append to data global as required and get data on each check, not only for complete requests?

And also, I see beg security Issue, when I can get information from any other process. You use TaskId directly from the request like you trust everybody. And also easy to get SUBSCRIPT error.

I completely agree that it's unsecure and with no $get(). But it's a minimal implementation, so I skipped a lot of details.

BTW: do you suppose to acept someone's answer? Looks like it is mostly just discissing topic.

I think it's more of a discussion topic. That's why it's an article and not a question.

You're getting an error:

:ERROR{ERROR #5002: Cache error: <PROPERTY DOES NOT EXIST>zXMLTOJson+6^TestEnvironment.Custom.GENERAL.CUSTOM.XLT.XMLToJsonOperation1.1 *Parameters,EnsLib.EDI.XML}

Which means :

  • Class is EnsLib.EDI.XML
  • It does not have Parameters property
  • Error is found in the 6th line of zXMLTOJson routine in TestEnvironment.Custom.GENERAL.CUSTOM.XLT.XMLToJsonOperation1.1

6th line is probably this:

 Set tSC = ..Transform(tInput,tSSKey,pRequest.Parameters,.tOutput)

and pRequest object (of EnsLib.EDI.XML class) does not have Parameters property. Your call should probably be:

 Set tSC = ..Transform(tInput,tSSKey,pRequest,.tOutput)

I first translated each word into normalized form - array of [letter, number of occurrences], ordered by letters. And then just checked if given normalized form already exists:

ClassMethod IsLettersUnique(word) As %Boolean
{
    set length = $length(word)
    for i=1:1:length {
        set letter = $e(word, i)
        set temp(letter) = $i(temp(letter))
    }
    
    set normalized = ""
    set key = ""
    for {
        set key=$order(temp(key),1, occurrences)
        quit:key=""
        set normalized = normalized _ key _ occurrences
    }
    
    quit:$d(%normalized(normalized))>0 $$$NO
    
    set %normalized(normalized) = 1
    
    quit $$$YES
}

Normalized words:

  • aaba -> a3b1
  • aaab -> a3b1

Add:

Set email.Charset = "UTF-8"
Set email.IsHTML = $$$YES

and add text in html, for example:

Do email.TextData.Write($$$FormatText("Hello %1!<br>Thank you for visiting %2!", "Name", "Location"))

Also if your BO has only one method you can name in OnMessage and remove XData altogether.

If new lines is really the only thing you need formatting-wise, you can use WriteLine method and send plain text emails:

Do email.TextData.WriteLine($$$FormatText("Thank you for your recent visit to %1.", "Location"))
Do email.TextData.WriteLine("We continue to look for ways to improve and your feedback is important.")
Do email.TextData.WriteLine($$$FormatText("Please take a few moments to complete our survey by following the link provided below, or by completing the paper survey you may have received at discharge from your recent visit at %1.", "Location"))

I'm in. Here's my solution.

Thought about using $zstrip, but while it can remove duplicates, it can't leave only duplicates:

w $zstrip("11223","=E")
123

 

Also, for second task it says:

1212 produces 6: the list contains 4 items, and all four digits match the digit 2 items ahead.
1221 produces 0, because every comparison is between a 1 and a 2.

Shouldn't 1221 produce 3 as first 2 and second 1 match.

Currently failed on second task with 10938.

URL map can also be splitted into several parts:

XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>

<!-- Api version 1 -->
<Map Prefix="/v1" Forward="Api.v1"/>

<!-- Api version 2 -->
<Map Prefix="/v2" Forward="Api.v2"/>

</Routes>
}

And brokers in Api.v1 and Api.v2 would process the requests according to their URL Map.

cpf files.

All classes from Config package affect one of cpf file (active one by default). But you also need to save and activate modified config file. Dmitry solution does that all by default. Which is fine if you want to add one mapping, but if you want to modify several Config settings it's better to modify them and activate the changes separately. For example here's mapping several packages to %ALL.

#include %syConfig
set namespace = "%ALL"
set namespace = $zcvt(namespace, "U")
for package = "Package1","Package2","Package3" {
    kill p
    set p("Database")=pFrom
    set sc = ##Class(Config.MapPackages).Create(namespace, package,.p,,$$$CPFSave)
}
set sc = ##Class(Config.CPF).Write()
set sc = ##Class(Config.Map).MoveToActive(namespace)
set sc = ##Class(Config.Namespaces).Load(namespace)

You can add Ens.ProductionMonitorService service to your production, which would provides a monitor service for the production status The default behavior of this service is to call UpdateProduction once it notices the production is not up-to-date. Users can override the OnProcessInput method to customize the behavior.

It would be enough to automatically restart relevant items and keep production up to date.

Generally to access/manipulate info about Ensemble and it's hosts use Ens.Director class.