go to post Thembelani Mlalazi · Jan 15, 2018 @David Foard In your Rule on the when condition select the (Document.RecordMapper.Property) make show you are referencing a record mapper on the constraint of the rule
go to post Thembelani Mlalazi · Jan 5, 2018 I have changed it to class method and still same error@Eduard Lebedyuk
go to post Thembelani Mlalazi · Jan 5, 2018 that's is the only way I could do it have any suggestion on how I can Improve that thank you@Robert.Cemper
go to post Thembelani Mlalazi · Jan 4, 2018 so far when I run my code in cache I get this error <INVALID OREF>zXmlToJSONnode+3^SharpJSONToXML.1 and I would like to know the equivalent in cache for that method if you look at it@Robert.Cemper
go to post Thembelani Mlalazi · Dec 20, 2017 @eduard.lebeduk I am not using %XML.Reader hence the reason I need to find the alternative of reading the record open and close element I am trying to do away with creating object classes
go to post Thembelani Mlalazi · Dec 20, 2017 @Fabian.Haupt I need help if Xpath will achieve what I am trying to do so be it what I want is something generic for any XML to be processed if Xpath Has a generic way fine
go to post Thembelani Mlalazi · Dec 14, 2017 @Eduard Lebedyukyes that the expected results even if you can not move the last two elements to be last just making something similar might help
go to post Thembelani Mlalazi · Dec 14, 2017 @Eduard Lebedyuksorry man given the above XLT how can I get the following Json {"Body" : [{"Code" : "HOT","Name" : "SIDE","Type" : "AADULT","Sec" : "MSec","ardge" : "Adult","Nder" : "F","TBC" : "21","BO" : "14","DBOC" : "0","LBC" : "5","AB" : "2"},{"Code" : "HOT","Name" : "DARS","Type" : "AADULT","Sec" : "MSec","ardge" : "OADULT","Nder" : "U","TBC" : "20","BO" : "16","DBOC" : "0","LBC" : "2","AB" : "2"}]"Code" : "HOT","Date" : "2017-12-08 11:22:34.658",}
go to post Thembelani Mlalazi · Dec 8, 2017 Thanks for the advice have changed my code but come to a problem while reading my stream as there seems to an error with the XSLT XML Transformer Error: SAXParseException I do not seems to see what the problem is as I tested my XLT with the XLT Transform Wizard and it all worked fine could you please have a look at the xml and the XLT and see if you can spot where I am going wrong thanks in advance XML <Message><Header><Code>HOT</Code><Date>2017-12-08 11:22:34.658</Date></Header><Body><Code>HOT</Code><Name>SIDE</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>F</Nder><TBC>21</TBC><BO>14</BO><DBOC>0</DBOC><LBC>5</LBC><AB>2</AB></Body><Body><Code>HOT</Code><Name>DARS</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>OADULT</ardge><Nder>U</Nder><TBC>20</TBC><BO>16</BO><DBOC>0</DBOC><LBC>2</LBC><AB>2</AB></Body><Body><Code>HOT</Code><Name>ENTLE</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>M</Nder><TBC>22</TBC><BO>18</BO><DBOC>0</DBOC><LBC>3</LBC><AB>1</AB></Body><Body><Code>HOT</Code><Name>ROOXED</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>OADULT</ardge><Nder>U</Nder><TBC>17</TBC><BO>7</BO><DBOC>0</DBOC><LBC/><AB>9</AB></Body><Body><Code>HOT</Code><Name>DUK</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>F</Nder><TBC>20</TBC><BO>17</BO><DBOC>0</DBOC><LBC>1</LBC><AB>2</AB></Body><Body><Code>HOT</Code><Name>DALE</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>M</Nder><TBC>18</TBC><BO>15</BO><DBOC>0</DBOC><LBC>2</LBC><AB/></Body><Body><Code>HOT</Code><Name>DAN</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>OADULT</ardge><Nder>U</Nder><TBC>16</TBC><BO>8</BO><DBOC>0</DBOC><LBC/><AB>8</AB></Body><Body><Code>HOT</Code><Name>DUN</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>U</Nder><TBC>2</TBC><BO>0</BO><DBOC>0</DBOC><LBC>1</LBC><AB>1</AB></Body><Body><Code>HOT</Code><Name>DUW</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>U</Nder><TBC>3</TBC><BO>2</BO><DBOC>0</DBOC><LBC>1</LBC><AB/></Body><Body><Code>HOT</Code><Name>DUM</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>OADULT</ardge><Nder>U</Nder><TBC>22</TBC><BO>18</BO><DBOC>0</DBOC><LBC>2</LBC><AB>2</AB></Body><Body><Code>HOT</Code><Name>DUR</Name><Type>AADULT</Type><Sec>MSec</Sec><ardge>Adult</ardge><Nder>U</Nder><TBC>16</TBC><BO>13</BO><DBOC>0</DBOC><LBC>2</LBC><AB/></Body></Message> XSLT <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text" indent="yes"/> <xsl:template match="/*[node()]"> <xsl:text>{</xsl:text><xsl:text>
</xsl:text> <xsl:apply-templates select="." mode="detect" /> <xsl:text>
</xsl:text> <xsl:text>}</xsl:text> </xsl:template> <xsl:template match="*" mode="detect"> <xsl:choose> <xsl:when test="name(preceding-sibling::*[1]) = name(current()) and name(following-sibling::*[1]) != name(current())"> <xsl:apply-templates select="." mode="obj-content" /> <xsl:text>
</xsl:text> <xsl:text>]</xsl:text> <xsl:if test="count(following-sibling::*[name() != name(current())]) > 0">, </xsl:if> </xsl:when> <xsl:when test="name(preceding-sibling::*[1]) = name(current())"> <xsl:apply-templates select="." mode="obj-content" /> <xsl:if test="name(following-sibling::*) = name(current())">, </xsl:if> </xsl:when> <xsl:when test="following-sibling::*[1][name() = name(current())]"> <xsl:text>"</xsl:text><xsl:value-of select="name()"/><xsl:text>" : [</xsl:text> <xsl:text>
</xsl:text> <xsl:apply-templates select="." mode="obj-content" /><xsl:text>, </xsl:text> <xsl:text>
</xsl:text> </xsl:when> <xsl:when test="count(./child::*) > 0 or count(@*) > 0"> <xsl:text>"</xsl:text><xsl:value-of select="name()"/>" : <xsl:apply-templates select="." mode="obj-content" /> <xsl:if test="count(following-sibling::*) > 0">, </xsl:if> </xsl:when> <xsl:when test="count(./child::*) = 0"> <xsl:text>"</xsl:text><xsl:value-of select="name()"/>" : "<xsl:apply-templates select="."/><xsl:text>"</xsl:text> <xsl:if test="count(following-sibling::*) > 0">, </xsl:if> <xsl:text>
</xsl:text> </xsl:when> </xsl:choose> </xsl:template> <xsl:template match="*" mode="obj-content"> <xsl:text>
</xsl:text> <xsl:text>{</xsl:text> <xsl:text>
</xsl:text> <xsl:apply-templates select="@*" mode="attr" /> <xsl:if test="count(@*) > 0 and (count(child::*) > 0 or text())">, </xsl:if> <xsl:apply-templates select="./*" mode="detect" /> <xsl:if test="count(child::*) = 0 and text() and not(@*)"> <xsl:text>"</xsl:text><xsl:value-of select="name()"/>" : "<xsl:value-of select="text()"/><xsl:text>"</xsl:text> </xsl:if> <xsl:if test="count(child::*) = 0 and text() and @*"> <xsl:text>"text" : "</xsl:text><xsl:value-of select="text()"/><xsl:text>"</xsl:text> </xsl:if> <xsl:text>}</xsl:text> <xsl:if test="position() < last()">, </xsl:if> </xsl:template> <xsl:template match="@*" mode="attr"> <xsl:text>"</xsl:text><xsl:value-of select="name()"/>" : "<xsl:value-of select="."/><xsl:text>"</xsl:text> <xsl:if test="position() < last()">,</xsl:if> </xsl:template> <xsl:template match="node/@TEXT | text()" name="removeBreaks"> <xsl:param name="pText" select="normalize-space(.)"/> <xsl:choose> <xsl:when test="not(contains($pText, '
'))"><xsl:copy-of select="$pText"/></xsl:when> <xsl:otherwise> <xsl:value-of select="concat(substring-before($pText, '
'), ' ')"/> <xsl:call-template name="removeBreaks"> <xsl:with-param name="pText" select="substring-after($pText, '
')"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template> </xsl:stylesheet>
go to post Thembelani Mlalazi · Dec 4, 2017 that works wonders with the use of the following class http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GXML_xslt
go to post Thembelani Mlalazi · Nov 15, 2017 @Marc Mundt I have read around the topic but still cannot figure out how to read an xml to %ZEN.proxyObject would mind please giving us an example to work with I am still new to this thank you
go to post Thembelani Mlalazi · Nov 14, 2017 @Robert.Cemper thank you but I am trying to avoid using the object classes to create this as I will be processing a lot of different files and will end up with a lot of classes
go to post Thembelani Mlalazi · Nov 9, 2017 [@ vitaliy.Serdtsev] have change my code as per your suggestion still not writing to a file I get <PARAMETER>zWrite^%Stream.FileBinary.1
go to post Thembelani Mlalazi · Oct 24, 2017 yes it possible within your rule select the rule's constraint where you reference the source where the message is coming from and then click rule and add when on the condition for when select document . which will allow you to use the record mapper property
go to post Thembelani Mlalazi · Oct 23, 2017 Here is some code that will process your string container into lines of records that you want but you might want to change a few things to get this working with your records after converting your string container to a simple csv file you can then map it to your record mapper and process it any how. Class TestEnvironment.Custom.GENERAL.ContainerString Extends (%Persistent, %Populate, %XML.Adaptor, %ZEN.DataModel.Adaptor) { Property Mystring As %String(MAXLEN = 32000, XMLPROJECTION = "CONTENT"); ClassMethod Import() { // Create an instance of %XML.Reader Set reader = ##class(%XML.Reader).%New() // Begin processing of the file Set status = reader.OpenFile("C:\TEST\test.xml") If $$$ISERR(status) {do $System.Status.DisplayError(status)} // Associate a class name with the XML element name Do reader.Correlate("StringValue","TestEnvironment.Custom.GENERAL.ContainerString") // Read objects from xml file While (reader.Next(.object,.status)) { Write object.Mystring,! //check the length of the string set lstr=$length(object.Mystring,",") write "The length of incoming string is : "_lstr if (lstr>28) { //divide by 28 for your processing set div=lstr/28 if (div=2) { //assign your strings to something and write to file to map your records set newstrObject=$piece(object.Mystring,",",1,28) set secNewStrOJect=$piece(object.Mystring,",",29,56) } elseif (div=3) { set newstrObject=$piece(object.Mystring,",",1,28) set secNewStrOJect=$piece(object.Mystring,",",29,56) set thirdNewStrOJect=$piece(object.Mystring,",",57,84) write "this is the string cut1 :"_newstrObject,! write "this is the string cut2 :"_secNewStrOJect,! write "this is the string cut3 :"_thirdNewStrOJect,! }} } // If error found during processing, show it If $$$ISERR(status) {do $System.Status.DisplayError(status)} } } hope this helps