Question
· Sep 20

xml attribute in double quotes

I am converting a HL7 msg to xml and one of the field is as below -
 
DTL = <assign value='"Message"' property='target.{req.ID.scope}' action='set' />

DTL response = <ID scope='Message'>3</ID>

my xsd has -
<xsd:element name="ID">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="SimpleContent" minOccurs="0"/>
</xsd:sequence>
<xsd:attribute name="scope"/>
</xsd:complexType>
</xsd:element>

I would like to get it DTL response as  = <ID scope="Message">3</ID>

Message in double quotes as - "Message"
Is there a way to get xml attribute in double quotes ? How can I do that ?

Discussion (4)2
Log in or sign up to continue

Where are you seeing "DTL response = <ID scope='Message'>3</ID>"?

What you see is the "representation", the "export" of your XML enabled class rendered by...whatever you are using to view/display it, the quotes are not part of the content.

How are you using/consuming your target (DTL response)? Some XML (SOAP? REST?) message? If so, I believe that you won't find single quotes when you will use it.

This is just guessing, because you don't provide any context/detail.

I think projecting as an attribute is enough. Here's an example:

Class Utils.Message Extends (%RegisteredObject, %XML.Adaptor)
{

Parameter XMLNAME = "ID";

Property scope As %String(XMLPROJECTION = "ATTRIBUTE");

}

DTL:

Class Utils.DTL Extends Ens.DataTransformDTL
{

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='Ens.Request' targetClass='Utils.Message' create='new' language='objectscript' >
<assign value='"Message"' property='target.scope' action='set' />
</transform>
}

/// do ##class(Utils.DTL).Test()
ClassMethod Test()
{
	set source = ##class(Ens.Request).%New()
	#dim target As Utils.Message
	set sc = ..Transform(source, .target)
	do target.XMLExportToString(.xml)
	w xml, !
}

}

Results in:

>do ##class(Utils.DTL).Test()

<ID scope="Message"></ID>