我的要求是通过一个日期来进行webservice调用,以便我获得自该日期以来已更改的所有记录。我正在使用Stylist Studio 2011进行开发。我设法得到一个减去2天的日期,但它总是返回一个时间:即2015-06-20-05:00但我只想要没有时间的日期。我已经尝试了substring,如下面的示例和日期格式,但我得到一个空结果。
此代码随时间返回:
{<?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>
}
结果是:
{
<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>
}
这是我的子串尝试
{<?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>
}
这是我的结果:
{`<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/"/>`
}
我尝试了所有这些的多种变体,我能说的最好的是我得到了一致的结果。我此刻只追逐自己的故事。
我自己解决了这个问题。以下是现在的工作:
{
<?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>
}
我回来了
{
<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>
}
所以我的新方法,因为我的应用程序不支持2.0是在xml中设置xml之前的值,如下所示(xml底部附近的lastChanged标记 - 这是在日志文件中输出) :
{
<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>
}
当我在造型师工作室测试时,我的xslt似乎有效。这是当前的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>
}
和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
}
答案 0 :(得分:0)
这最后一种方法是正确的,在引用xsl调用时,我只是通过文件名来查找。这个问题已经解决了。