This is my XML input that I have to transform:
<_-FOX_-SHPMNT06>
<IDOC BEGIN="1">
<E1EDT20 SEGMENT="1">
<TKNUM>8201333969</TKNUM>
<TPBEZ>FDC Domestic YT</TPBEZ`
<E1EDL20 SEGMENT="1">
<VBELN>3460011248</VBELN>
<E1EDT13 SEGMENT="1">
<QUALF>015</QUALF>
<NTANF>20181016</NTANF>
<NTANZ>000000</NTANZ>
<NTEND>20181016</NTEND>
<NTENZ>000000</NTENZ>
<ISDD>00000000</ISDD>
<ISDZ>000000</ISDZ>
<IEDD>00000000</IEDD>
<IEDZ>000000</IEDZ>
</E1EDT13>
<E1TXTH8 SEGMENT="1">
<TDOBJECT>VBBK</TDOBJECT>
<TDOBNAME>3460011248</TDOBNAME>
<TDID>Z022</TDID>
<TDSPRAS>D</TDSPRAS>
<LANGUA_ISO>DE</LANGUA_ISO>
<E1TXTP8 SEGMENT="1">
<TDFORMAT>*</TDFORMAT>
<TDLINE>Der Unterzeichner erklärt, dass die in diesem Dokument aufgeführten</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDLINE>Waren Ursprungserzeugnisse aus China sind und im Präferenzverkehr mit</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDLINE>CH-EU entsprechen.</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDFORMAT>*</TDFORMAT>
</E1TXTP8>
</E1TXTH8>
<E1TXTH8 SEGMENT="1">
<TDOBJECT>VBBK</TDOBJECT>
<TDOBNAME>3460011248</TDOBNAME>
<TDID>Z024</TDID>
<TDSPRAS>D</TDSPRAS>
<LANGUA_ISO>DE</LANGUA_ISO>
<E1TXTP8 SEGMENT="1">
<TDFORMAT>*</TDFORMAT>
<TDLINE>Ihre Artikelnr. 0068018</TDLINE>
</E1TXTP8>
</E1TXTH8>
</E1EDL20>
</E1EDT20>
</IDOC>
</_-FOX_-SHPMNT06>
and this is what I need as XML result:
<_-FOX_-SHPMNT06>
<IDOC BEGIN="1">
<E1EDT20 SEGMENT="1">
<TKNUM>8201333969</TKNUM>
<TPBEZ>FDC Domestic YT</TPBEZ>
<E1EDL20 SEGMENT="1">
<VBELN>3460011248</VBELN>
<E1TXTH8 SEGMENT="1">
<TDOBJECT/>
<TDOBNAME/>
<TDID/>
<TDSPRAS/>
<LANGUA_ISO/>
<E1TXTP8 SEGMENT="1">
<TDFORMAT/>
<TDLINE># 01 E Der Unterzeichner erklärt, dass die in diesem Dokument aufgeführten</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDFORMAT/>
<TDLINE># 02 E Waren Ursprungserzeugnisse aus China sind und im Präferenzverkehr mit</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDFORMAT/>
<TDLINE># 03 E CH-EU entsprechen.</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDFORMAT/>
<TDLINE># 04 E </TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDFORMAT/>
<TDLINE># 05 E Ihre Artikelnr. 0068018</TDLINE>
</E1TXTP8>
</E1TXTH8>
<E1TXTH8 SEGMENT="1">
<TDOBJECT>VBBK</TDOBJECT>
<TDOBNAME>3460011248</TDOBNAME>
<TDID>Z022</TDID>
<TDSPRAS>D</TDSPRAS>
<LANGUA_ISO>DE</LANGUA_ISO>
<E1TXTP8 SEGMENT="1">
<TDFORMAT>*</TDFORMAT>
<TDLINE>Der Unterzeichner erklärt, dass die in diesem Dokument aufgeführten</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDLINE>Waren Ursprungserzeugnisse aus China sind und im Präferenzverkehr mit</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDLINE>CH-EU entsprechen.</TDLINE>
</E1TXTP8>
<E1TXTP8 SEGMENT="1">
<TDFORMAT>*</TDFORMAT>
</E1TXTP8>
</E1TXTH8>
<E1TXTH8 SEGMENT="1">
<TDOBJECT>VBBK</TDOBJECT>
<TDOBNAME>3460011248</TDOBNAME>
<TDID>Z024</TDID>
<TDSPRAS>D</TDSPRAS>
<LANGUA_ISO>DE</LANGUA_ISO>
<E1TXTP8 SEGMENT="1">
<TDFORMAT>*</TDFORMAT>
<TDLINE>Ihre Artikelnr. 0068018</TDLINE>
</E1TXTP8>
</E1TXTH8>
</E1EDL20>
</E1EDT20>
</IDOC>
</_-FOX_-SHPMNT06>
I need to get a global counter instead of using "position()" because I don't want the counter to reset to 0 in every "for-each":
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" encoding="utf-8" indent="yes"/>
<!-- Identity template : copy all text nodes, elements and attributes -->
<xsl:template match="#*|node()">
<xsl:copy>
<xsl:apply-templates select="#*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="E1EDT13[position()=last()]">
<E1TXTH8 SEGMENT="1">
<TDOBJECT/>
<TDOBNAME/>
<TDID/>
<TDSPRAS/>
<LANGUA_ISO/>
<xsl:for-each select="following-sibling::E1TXTH8[TDID='Z002']/E1TXTP8">
<E1TXTP8 SEGMENT="1">
<xsl:variable name="typeA">A</xsl:variable>
<TDFORMAT/>
<TDLINE>
<xsl:value-of select="concat('#', ' ', format-number(position(),'00'), ' ', $typeA, ' ', TDLINE)"/>
</TDLINE>
</E1TXTP8>
</xsl:for-each>
<xsl:for-each select="following-sibling::E1TXTH8[TDID='Z022']/E1TXTP8">
<E1TXTP8 SEGMENT="1">
<xsl:variable name="typeE">E</xsl:variable>
<TDFORMAT/>
<TDLINE>
<xsl:value-of select="concat('#', ' ', format-number(position(),'00'), ' ', $typeE, ' ', TDLINE)"/>
</TDLINE>
</E1TXTP8>
</xsl:for-each>
<xsl:for-each select="following-sibling::E1TXTH8[TDID='Z024']/E1TXTP8">
<E1TXTP8 SEGMENT="1">
<xsl:variable name="typeE">E</xsl:variable>
<TDFORMAT/>
<TDLINE>
<xsl:value-of select="concat('#', ' ', format number(position(),'00'), ' ', $typeE, ' ', TDLINE)"/>
</TDLINE>
</E1TXTP8>
</xsl:for-each>
</E1TXTH8>
</xsl:template>
</xsl:stylesheet>
Is there any way to manage it ? If I use "position()" the counters will be 01 02 03 04 01 and I need 01 02 03 04 05 even if I have more "for each"
Related
I want to find the number of RegisterValueData elements inside the below structure for all the NewConsumptionData and RegisterConsumptionData elements, so a single figure.
<ConsumptionData>
<NewConsumptionData>
<FromDate>2021-02-02T00:00:00</FromDate>
<RegistersValues>
<RegisterConsumptionData>
<Timeframe>TOTAL_HOUR</Timeframe>
<Values>
<RegisterValueData>
<Quality>NONVALIDATED</Quality>
</RegisterValueData>
<RegisterValueData>
<Quality>VALIDATED</Quality>
</RegisterValueData>
</Values>
</RegisterConsumptionData>
<RegisterConsumptionData>
<Timeframe>TOTAL_HOUR</Timeframe>
<Values>
<RegisterValueData>
<Quality>NONVALIDATED</Quality>
</RegisterValueData>
<RegisterValueData>
<Quality>VALIDATED</Quality>
</RegisterValueData>
</Values>
</RegisterConsumptionData>
</RegistersValues>
</NewConsumptionData>
<NewConsumptionData>
<FromDate>2021-02-02T00:00:00</FromDate>
<RegistersValues>
<RegisterConsumptionData>
<Timeframe>TOTAL_HOUR</Timeframe>
<Values>
<RegisterValueData>
<Quality>NONVALIDATED</Quality>
</RegisterValueData>
<RegisterValueData>
<Quality>VALIDATED</Quality>
</RegisterValueData>
</Values>
</RegisterConsumptionData>
<RegisterConsumptionData>
<Timeframe>TOTAL_HOUR</Timeframe>
<Values>
<RegisterValueData>
<Quality>NONVALIDATED</Quality>
</RegisterValueData>
<RegisterValueData>
<Quality>VALIDATED</Quality>
</RegisterValueData>
</Values>
</RegisterConsumptionData>
</RegistersValues>
</NewConsumptionData>
What seems simple I cannot get my head around this. I am trying a recursive function (If that's the right way) but not sure how to set up the parameters and prevent it looping indefinitely.
You can easily use the count() function to count child or descendant nodes:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<result>
<xsl:value-of select="count(//RegisterValueData)" />
</result>
</xsl:template>
</xsl:stylesheet>
or a little more efficiently:
<xsl:template match="/ConsumptionData">
<result>
<xsl:value-of select="count(NewConsumptionData/RegistersValues/RegisterConsumptionData/Values/RegisterValueData)" />
</result>
</xsl:template>
Result
<?xml version="1.0" encoding="UTF-8"?>
<result>8</result>
Source XML :
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><SoapResponse
xmlns="http://tempuri.org/"><Response/><TicketId/><LogId/><Error xmlns:a="http://schemas.datacontract.org/2004/07/OpenSystems.Web.OCKSoap.Entities" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:code>1233</a:code><a:message>No se pudo obtener una conexión de base de datos</a:message></Error></SoapResponse></s:Body></s:Envelope>
Expected Target XML :
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_SAP_GoodsIssue_Res xmlns:ns0="http://www.aes.com/SapToOsf/GoodsIssue">
<SoapResponse>
<Response/>
<TicketId/>
<LogId/>
<Error>
<code/>
<message/>
</Error>
</SoapResponse>
</ns0:MT_SAP_GoodsIssue_Res>
I have tried with below XSLT but it didn't give proper result.
<xsl:template match="*">
<xsl:element name="{local-name()}" >
<xsl:apply-templates select="#* | node()"/>
</xsl:element>
</xsl:template>
XSLT O/P :
<?xml version="1.0" encoding="UTF-8"?><Envelope><Body><SoapResponse><Response/><TicketId/><LogId/><Error><code>1233</code><message>No se pudo obtener una conexi��n de base de datos</message></Error></SoapResponse></Body></Envelope>
Please help me to get expected output via XSLT.
My input XMl is
<?xml version="1.0" encoding="UTF-8"?>
<DEBMAS01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>2</DIRECT>
<IDOCTYP>DEBMAS01</IDOCTYP>
<MESTYP>DEBMAS</MESTYP>
<SNDPOR>MULESOFT</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>MULESOFT</SNDPRN>
<RCVPOR>MULESOFT</RCVPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>MULESOFT</RCVPRN>
</EDI_DC40>
<E1KNA1M SEGMENT="1">
<MSGFN>005</MSGFN>
<KUNNR>0000099500</KUNNR>
<KTOKD>ZAG2</KTOKD>
<LAND1>SK</LAND1>
<NAME1>Mulesoft 99003 2nd</NAME1>
<SPRAS>E</SPRAS>
<SPRAS_ISO>EN</SPRAS_ISO>
</E1KNA1M>
My expected output XML is
<?xml version="1.0" encoding="UTF-8"?>
<DEBMAS01>
<IDOC BEGIN="1">
<EDI_DC40 SEGMENT="1">
<TABNAM>EDI_DC40</TABNAM>
<DIRECT>2</DIRECT>
<IDOCTYP>DEBMAS01</IDOCTYP>
<MESTYP>DEBMAS</MESTYP>
<SNDPOR>PROJECT1</SNDPOR>
<SNDPRT>LS</SNDPRT>
<SNDPRN>MULESOFT</SNDPRN>
<RCVPOR>MULESOFT</RCVPOR>
<RCVPRT>LS</RCVPRT>
<RCVPRN>MULESOFT</RCVPRN>
</EDI_DC40>
<E1KNA1M SEGMENT="1">
<MSGFN>005</MSGFN>
<KUNNR>0000099500</KUNNR>
<KTOKD>ZAG2</KTOKD>
<LAND1>SK</LAND1>
<NAME1>Mulesoft 99003 2nd</NAME1>
<SPRAS>E</SPRAS>
<SPRAS_ISO>EN</SPRAS_ISO>
</E1KNA1M>
Here i just want to replace the string in SNDPOR tag from "MULESOFT" to "PROJECT1". I have achieved this using XSLT. But now i want to achieve this using Dataweave script. Kindly help.
Found the solution after going through the docs. Thanks to Rocco for enlightening me.
The solution is
%dw 1.0
%output application/xml
---
DEBMAS01 :{(payload map {
IDOC #(BEGIN:payload.DEBMAS01.IDOC.#BEGIN):{
EDI_DC40 #(SEGMENT:payload.DEBMAS01.IDOC.EDI_DC40.#SEGMENT):payload.DEBMAS01.IDOC.EDI_DC40 mapObject {
"$$" : $ unless "$$" ~="SNDPOR" otherwise "PROJECT1"
},
E1KNA1M #(SEGMENT:payload.DEBMAS01.IDOC.E1KNA1M.#SEGMENT):payload.DEBMAS01.IDOC.E1KNA1M mapObject {
"$$": $
}
}
})
}
My requirement is to make a webservice call passing a date so that I get all records back that have been changed since that date. I'm using Stylist Studio 2011 for my development. I've managed to get a date minus 2 days, but it always returns with a time: i.e. 2015-06-20-05:00 but I only want the date without the time. I have tried substring as in the following example and date format, but I get an empty result.
This code returns with time:
{<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vToday" select="current-date()"/>
<v1:lastChanged>
<xsl:value-of select="$vToday -2*xs:dayTimeDuration('P1D')"/>
</v1:lastChanged>
</xsl:template>
</xsl:stylesheet>
}
Results are:
{
<v1:lastChanged xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/">2015-06-20-05:00</v1:lastChanged>
}
This is my substring attempt
{<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vToday" select="current-date()"/>
<xsl:variable name="vTodayTrim" select="$vToday -2*xs:dayTimeDuration('P1D')"/>
<xsl:variable name="vTodayDate" fn:substring="(vTodayTrim,1 ,10)"/>
<v1:lastChanged>
<xsl:value-of select="vTodayDate"/>
</v1:lastChanged>
</xsl:template>
</xsl:stylesheet>
}
This is my result:
{`<v1:lastChanged xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/"/>`
}
I've tried multiple variations of all this and the best I can say is I get consistent results. I'm only chasing my tale at this point.
I solved this one on my own. Here is what have working now:
{
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:mro="http://www.ibm.com/maximo"
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:variable name="vToday" select="current-date()"/>
<xsl:variable name="vTodayTrim" select="$vToday -2*xs:dayTimeDuration('P1D')"/>
<v1:lastChanged>
<xsl:value-of select="substring($vTodayTrim,1,10)"/>
</v1:lastChanged>
</xsl:template>
</xsl:stylesheet>
}
and I get back
{
<v1:lastChanged xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mro="http://www.ibm.com/maximo" xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/">2015-06-20</v1:lastChanged>
}
So my new approach since my application doesn't support 2.0 is to set the value in xml prior to putting it through the xslt as in the following (lastChanged tag near bottom of xml - this is output in the logfile):
{
<InvokeNASAPERSON xmlns="http://www.ibm.com/maximo" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" creationDateTime="2015-06-25T11:30:04-05:00" transLanguage="EN" baseLanguage="EN" messageID="1435249805139258092" maximoVersion="7 5 20130829-1209 V7510--1">
<NASAPERSONSet>
<PERSON>
<DEPARTMENT />
<DISPLAYNAME>MAXADMIN</DISPLAYNAME>
<DROPPOINT />
<FIRSTNAME />
<LASTNAME />
<LOCATION />
<LOCATIONORG />
<NASACENTER />
<NASAFUNDINGORG />
<NP_STATUSMEMO />
<OWNERSYSID />
<PERSONID>MAXADMIN</PERSONID>
<PERSONUID>3</PERSONUID>
<PRIMARYEMAIL>jreeve#cohesivesolutions.com</PRIMARYEMAIL>
<PRIMARYPHONE>423 314 1312</PRIMARYPHONE>
<SENDERSYSID>MX</SENDERSYSID>
<SOURCESYSID />
<STATUS maxvalue="ACTIVE">ACTIVE</STATUS>
<STATUSDATE>2004-04-14T11:58:32-05:00</STATUSDATE>
<STATUSIFACE>0</STATUSIFACE>
<SUPERVISOR />
<TITLE />
<PHONE>
<ISPRIMARY>1</ISPRIMARY>
<PHONEID>82</PHONEID>
<PHONENUM>423 314 1312</PHONENUM>
<TYPE />
</PHONE>
<EMAIL>
<EMAILADDRESS>jreeve#cohesivesolutions.com</EMAILADDRESS>
<EMAILID>122</EMAILID>
</EMAIL>
<lastChanged>2015-06-23</lastChanged>
</PERSON>
</NASAPERSONSet>
</InvokeNASAPERSON>
}
My xslt seems to work when I test it in stylist studio. Here is the current xslt
{
<?xml version='1.0' ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:mro="http://www.ibm.com/maximo" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v1="http://types.msfc.nasa.gov/personnel/messages/v1/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/mro:InvokeNASAPERSON/mro:NASAPERSONSet/mro:PERSON">
<v1:PersonQueryRequest>
<v1:lastChanged>
<xsl:value-of select="mro:lastChanged"/>
</v1:lastChanged>
</v1:PersonQueryRequest>
</xsl:template>
</xsl:stylesheet>
}
and the stacktrace
{End of input XML
[6/25/15 11:30:06:075 CDT] 00000120 SystemOut O 25 Jun 2015 11:30:06:075 [ERROR] [MXServer] [CID-CRON-265] com.ibm.xtq.xslt.jaxp.HandledRuntimeException: [ERR 0641] An error occurred while parsing document: 'Content is not allowed in prolog.'.
javax.xml.transform.TransformerConfigurationException: com.ibm.xtq.xslt.jaxp.HandledRuntimeException: [ERR 0641] An error occurred while parsing document: 'Content is not allowed in prolog.'.
at com.ibm.xtq.xslt.jaxp.AbstractTransformerFactory.newTemplates(Unknown Source)
at psdi.common.xsl.XSLTransformerCache.createTransformer(XSLTransformerCache.java:96)
at psdi.common.xsl.XSLTransformerCache.getTransformer(XSLTransformerCache.java:67)
at psdi.common.xsl.XSLTransformer.getTransformerFromPath(XSLTransformer.java:143)
at psdi.common.xsl.XSLTransformer.transform(XSLTransformer.java:129) at psdi.iface.migexits.ExitProcessor.mapData(ExitProcessor.java:607)
at psdi.iface.migexits.ExitProcessor.executeOutExitLogic(ExitProcessor.java:458)
at psdi.iface.migexits.ExitProcessor.processTheseExitsOut(ExitProcessor.java:342)
at psdi.iface.migexits.ExitProcessor.processExitsOut(ExitProcessor.java:157)
at psdi.iface.mic.InvokeChannel.processExitsOut(InvokeChannel.java:329)
at psdi.iface.mic.InvokeChannel.invoke(InvokeChannel.java:102)
at psdi.iface.action.InvokeCustomClass.applyCustomAction(InvokeCustomClass.java:109)
at psdi.common.action.Action.executeCustomClass(Action.java:399)
at psdi.common.action.Action.executeAction(Action.java:311)
at psdi.common.action.Action.executeActionGroup(Action.java:365)
at psdi.common.action.Action.executeAction(Action.java:331)
at psdi.common.action.Action.executeAction(Action.java:344)
at psdi.app.escalation.engine.EscalationTask.executeAction(EscalationTask.java:1454)
at psdi.app.escalation.engine.EscalationTask.executeActions(EscalationTask.java:1372)
at psdi.app.escalation.engine.EscalationTask.executeReferencePoint(EscalationTask.java:622)
at psdi.app.escalation.engine.EscalationTask.processReferencePoint(EscalationTask.java:520)
at psdi.app.escalation.engine.EscalationTask.performTask(EscalationTask.java:175)
at psdi.app.escalation.engine.EscalationCronTask.cronAction(EscalationCronTask.java:46)
at psdi.server.CronTaskManager.callCronMethod(CronTaskManager.java:1590)
at psdi.server.CronTaskManager.access$400(CronTaskManager.java:87)
at psdi.server.CronTaskManager$CronThread.run(CronTaskManager.java:2156)
Caused by: com.ibm.xtq.xslt.jaxp.HandledRuntimeException: [ERR 0641] An error occurred while parsing document: 'Content is not allowed in prolog.'.
at com.ibm.xtq.xslt.jaxp.ConfigurationErrorHandler.report(Unknown Source)
at com.ibm.xtq.utils.Reporter.report(Unknown Source)
at com.ibm.xtq.ast.parsers.xslt.XSLTParser.reportError(Unknown Source)
at com.ibm.xtq.ast.parsers.xslt.XSLTParser.parse(Unknown Source)
at com.ibm.xtq.ast.parsers.xslt.XSLTParser.parse(Unknown Source)
at com.ibm.xtq.xslt.drivers.XSLTCompiler.makeAST(Unknown Source)
at com.ibm.xtq.xslt.drivers.XSLTCompiler.buildAST(Unknown Source)
at com.ibm.xtq.xslt.drivers.XSLTCompiler.compile(Unknown Source)
at com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl.createTemplates(Unknown Source)
... 26 more
[6/25/15 11:30:06:090 CDT] 00000120 SystemOut O 25 Jun 2015 11:30:06:075 [ERROR] [MXServer] [CID-CRON-265] Failed to execute action on escalation: {NASAPERSONWS} reference point: {155} for object {PERSON} with id {3}
psdi.util.MXSystemException: BMXAA4214E - An unknown error has occurred.
Please contact your system administrator for assistance. Gather the logs from the <HOME> directory and determine where and why the error is thrown.
com.ibm.xtq.xslt.jaxp.HandledRuntimeException: [ERR 0641] An error occurred while parsing document: 'Content is not allowed in prolog.'.
at psdi.iface.migexits.ExitProcessor.mapData(ExitProcessor.java:630)
at psdi.iface.migexits.ExitProcessor.executeOutExitLogic(ExitProcessor.java:458)
at psdi.iface.migexits.ExitProcessor.processTheseExitsOut(ExitProcessor.java:342)
at psdi.iface.migexits.ExitProcessor.processExitsOut(ExitProcessor.java:157)
at psdi.iface.mic.InvokeChannel.processExitsOut(InvokeChannel.java:329)
at psdi.iface.mic.InvokeChannel.invoke(InvokeChannel.java:102)
at psdi.iface.action.InvokeCustomClass.applyCustomAction(InvokeCustomClass.java:109)
at psdi.common.action.Action.executeCustomClass(Action.java:399)
at psdi.common.action.Action.executeAction(Action.java:311)
at psdi.common.action.Action.executeActionGroup(Action.java:365)
at psdi.common.action.Action.executeAction(Action.java:331)
at psdi.common.action.Action.executeAction(Action.java:344)
at psdi.app.escalation.engine.EscalationTask.executeAction(EscalationTask.java:1454)
at psdi.app.escalation.engine.EscalationTask.executeActions(EscalationTask.java:1372)
at psdi.app.escalation.engine.EscalationTask.executeReferencePoint(EscalationTask.java:622)
at psdi.app.escalation.engine.EscalationTask.processReferencePoint(EscalationTask.java:520)
at psdi.app.escalation.engine.EscalationTask.performTask(EscalationTask.java:175)
at psdi.app.escalation.engine.EscalationCronTask.cronAction(EscalationCronTask.java:46)
at psdi.server.CronTaskManager.callCronMethod(CronTaskManager.java:1590)
at psdi.server.CronTaskManager.access$400(CronTaskManager.java:87)
at psdi.server.CronTaskManager$CronThread.run(CronTaskManager.java:2156)
Caused by: javax.xml.transform.TransformerConfigurationException: com.ibm.xtq.xslt.jaxp.HandledRuntimeException: [ERR 0641] An error occurred while parsing document: 'Content is not allowed in prolog.'.
at com.ibm.xtq.xslt.jaxp.AbstractTransformerFactory.newTemplates(Unknown Source)
at psdi.common.xsl.XSLTransformerCache.createTransformer(XSLTransformerCache.java:96)
at psdi.common.xsl.XSLTransformerCache.getTransformer(XSLTransformerCache.java:67)
at psdi.common.xsl.XSLTransformer.getTransformerFromPath(XSLTransformer.java:143)
at psdi.common.xsl.XSLTransformer.transform(XSLTransformer.java:129)
at psdi.iface.migexits.ExitProcessor.mapData(ExitProcessor.java:607)
... 20 more
Caused by: com.ibm.xtq.xslt.jaxp.HandledRuntimeException: [ERR 0641] An error occurred while parsing document: 'Content is not allowed in prolog.'.
at com.ibm.xtq.xslt.jaxp.ConfigurationErrorHandler.report(Unknown Source)
at com.ibm.xtq.utils.Reporter.report(Unknown Source)
at com.ibm.xtq.ast.parsers.xslt.XSLTParser.reportError(Unknown Source)
at com.ibm.xtq.ast.parsers.xslt.XSLTParser.parse(Unknown Source)
at com.ibm.xtq.ast.parsers.xslt.XSLTParser.parse(Unknown Source)
at com.ibm.xtq.xslt.drivers.XSLTCompiler.makeAST(Unknown Source)
at com.ibm.xtq.xslt.drivers.XSLTCompiler.buildAST(Unknown Source)
at com.ibm.xtq.xslt.drivers.XSLTCompiler.compile(Unknown Source)
at com.ibm.xtq.xslt.jaxp.compiler.TransformerFactoryImpl.createTemplates(Unknown Source)
... 26 more
}
This last approach was correct, I just fat fingered by filename when referencing the xsl call. This issues is resolved.
Using the following input XML, my goal is to initially select portfolios/portfolio node, then the <tradeContribution> child nodes - specifically contributions/tradeContribution .
These tradeContribution nodes will then be transformed into the <trade> nodes in the xml output shown below.
My xml output and XSLT code follows below...
<outBound>
<requestReceivedTime>2014-05-15 15:20:42.279</requestReceivedTime>
<responseSentTime>2014-05-15 15:20:42.338</responseSentTime>
<body>
<portfolios>
<portfolio id="36" nodeDate="2014-05-06">
<query>
<firstTerm>
<date>2014-05-06</date>
</firstTerm>
<lastTerm>
<date>2014-05-06</date>
</lastTerm>
</query>
<exposure>492691.50878619519</exposure>
<contributions>
<tradeContribution contextId="0" contribution="267624.242492124" dealId="IRSW-TRADE-00011" desc="IRSW-FIX-FLOAT" order="0" sysId="1" tradeId="IRSW-TRADE-00011">
<hideTrade>false</hideTrade>
<readOnly>false</readOnly>
</tradeContribution>
<tradeContribution contextId="7" contribution="225067.26629407122" dealId="IRSW-TRADE-00020" desc="IRSW-FIX-FLOAT" order="1" sysId="2" tradeId="IRSW-TRADE-00020">
<hideTrade>false</hideTrade>
<readOnly>false</readOnly>
</tradeContribution>
</contributions>
<nodeAnalysis id="HSVaR 5D 100 ES">
<method>INTERPOLATED_EXPECTED_SHORTFALL</method>
<exposure>true</exposure>
<percentile>100</percentile>
</nodeAnalysis>
</portfolio>
</portfolios>
</body>
</outBound>
My desired XML output is:
<?xml version="1.0" ?>
<collection>
<trade>
<legal_id>36</legal_id>
<tradeRef>IRS-RRT-002</tradeRef>
<system>MY SYSTEM IRS</system>
<indepMtmValuation>111111</indepMtmValuation>
<indepMtmValuationCcy>USD</indepMtmValuationCcy>
<principalDealLevelUpfront>TRUE</principalDealLevelUpfront>
<principalDealLevelAmount>14</principalDealLevelAmount>
<principalDealLevelCurrency>USD</principalDealLevelCurrency>
<principalDealLevelType>Independent Amount</principalDealLevelType>
<operation>U</operation>
</trade>
<trade>
<legal_id>36</legal_id>
<system>MY SYSTEM CDS</system>
<tradeRef>CDS-RRT-008</tradeRef>
<mtmValuation>222222</mtmValuation>
<mtmValuationDate>2013-09-11</mtmValuationDate>
<mtmValuationLocalSysCcy>USD</mtmValuationLocalSysCcy>
<counterpartyDealLevelUpfront>TRUE</counterpartyDealLevelUpfront>
<counterpartyDealLevelAmount>15</counterpartyDealLevelAmount>
<counterpartyDealLevelCurrency>JPY</counterpartyDealLevelCurrency>
<counterpartyDealLevelType>Independent Amount</counterpartyDealLevelType>
</trade>
</collection>
The XSLT I have so far is as follows; however, I have a problem:
1) Trying to find the best way to pull the value of attribute "id", which is part of <portfolio id="36" nodeDate="2014-05-06"> .
I need to output it to <legal_id>, but this here is NOT working:
<legal_id><xsl:value-of select="../portfolio[#id]"/></legal_id>
Your advice would be greatly appreciate in helping to properly construct my XSLT to produce the desired XML output shown above:
My XSLT code thus far:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
exclude-result-prefixes="xs xd"
version="1.0">
<!-- Variable declaration -->
<xsl:variable name="hsVar1D" select="'1D (99%)'"></xsl:variable>
<xsl:variable name="hsVar5D" select="'HSVaR 5D 100 ES'"></xsl:variable>
<xsl:template match="/*">
<collection>
<xsl:apply-templates select="/outbound/body/portfolios/portfolio[descendant::nodeAnalysis[#id[contains(.,$hsVar5D)]]]" />
</collection>
</xsl:template>
<xsl:template match="*">
<xsl:apply-templates select="contributions/tradeContribution"/>
</xsl:template>
<xsl:template match="contributions/tradeContribution">
<trade>
<!-- QUESTION: For <legal_id> what is the best way to select the #id attrib from the ancestor node <portfolio> -->
<legal_id><xsl:value-of select="#id"/></legal_id>
<legal_id222><xsl:value-of select="../portfolio[#id]"/></legal_id222>
<tradeRef>IRS-RRT-002</tradeRef>
<system>MY SYSTEM IRS</system>
<indepMtmValuation>111111</indepMtmValuation>
<indepMtmValuationCcy>USD</indepMtmValuationCcy>
<principalDealLevelUpfront>TRUE</principalDealLevelUpfront>
<principalDealLevelAmount><xsl:value-of select="exposure"></xsl:value-of></principalDealLevelAmount>
<principalDealLevelCurrency>USD</principalDealLevelCurrency>
<principalDealLevelType>Independent Amount</principalDealLevelType>
<operation>U</operation>
</trade>
</xsl:template>
Try it this way:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<!-- Variable declaration -->
<xsl:variable name="hsVar1D" select="'1D (99%)'"></xsl:variable>
<xsl:variable name="hsVar5D" select="'HSVaR 5D 100 ES'"></xsl:variable>
<xsl:template match="/">
<collection>
<xsl:apply-templates select="outBound/body/portfolios/portfolio[nodeAnalysis[contains(#id,$hsVar5D)]]/contributions/tradeContribution" />
</collection>
</xsl:template>
<xsl:template match="tradeContribution">
<trade>
<legal_id>
<xsl:value-of select="../../../portfolio/#id"/>
</legal_id>
<tradeRef>IRS-RRT-002</tradeRef>
<system>RAZOR IRS</system>
<indepMtmValuation>111111</indepMtmValuation>
<indepMtmValuationCcy>USD</indepMtmValuationCcy>
<principalDealLevelUpfront>TRUE</principalDealLevelUpfront>
<principalDealLevelAmount>
<xsl:value-of select="../../nodeAnalysis/exposure"/>
</principalDealLevelAmount>
<principalDealLevelCurrency>USD</principalDealLevelCurrency>
<principalDealLevelType>Independent Amount</principalDealLevelType>
<operation>U</operation>
</trade>
</xsl:template>
</xsl:stylesheet>
--
Note outBound vs. razorOutbound