XML 양식의 타임 스탬프에서 밀리 초를 제거하는 XSLT 스타일 시트를 작성하려고합니다. 아래의 샘플 XML은 엔벨로프에 타임 스탬프가 여러 개있을 수있는 샘플입니다. 그래서 나는 타임 스탬프와 패턴을 일치시켜야한다고 생각하고있다.타임 스탬프에서 밀리 초를 제거하는 XSLT
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header>
<soap:Body>
<Staging_Submit_Service xmlns="com.xxx">
<u_From_Partner__c>Our Partner</u_From_Partner__c>
<u_To_Partner__c>Us</u_To_Partner__c>
<u_Partner_CI__c/>
<u_Partner_ID__c>10051</u_Partner_ID__c>
<u_Partner_Name__c>ROSEVILLE</u_Partner_Name__c>
<u_Partner_Reported_Date__c>2016-07-26T17:38:28.746134Z</u_Partner_Reported_Date__c>
<u_Partner_Status_Reason__c>Failure in System</u_Partner_Status_Reason__c>
<u_Partner_Submit_Date__c>2016-07-25T18:11:23.5443Z</u_Partner_Submit_Date__c>
<u_Partner_Priority__c>Low</u_Partner_Priority__c>
<u_Partner_Service_Type>Event</u_Partner_Service_Type>
</Staging_Submit_Service>
</soap:Body>
</soap:Envelope>
내 결과 XML이 같이 할 필요가 :
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
</soap:Header><soap:Body>
<Staging_Submit_Service xmlns="com.xxx">
<u_From_Partner__c>Our Partner</u_From_Partner__c>
<u_To_Partner__c>Us</u_To_Partner__c>
<u_Partner_CI__c/>
<u_Partner_ID__c>10051</u_Partner_ID__c>
<u_Partner_Name__c>ROSEVILLE</u_Partner_Name__c>
<u_Partner_Reported_Date__c>2016-07-26T17:38:28Z</u_Partner_Reported_Date__c>
<u_Partner_Status_Reason__c>Failure in System</u_Partner_Status_Reason__c>
<u_Partner_Submit_Date__c>2016-07-25T18:11:23Z</u_Partner_Submit_Date__c>
<u_Partner_Priority__c>Low</u_Partner_Priority__c>
<u_Partner_Service_Type>Event</u_Partner_Service_Type>
</Staging_Submit_Service>
</soap:Body>
</soap:Envelope>
공지 타임 스탬프 나는 원본 메시지의 모양 XSLT 2.0을 사용할 수 있습니다. 나는이 길을 시작했지만, 내가 있어야 할 곳을 찾지 못하는 것 같습니다.
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns1="java:com.verizon.webservices.adapter.clecclient">
<xsl:output method="xml" indent="no" version="1.0" encoding="UTF-8" omit-xml-declaration="yes"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()"
<xsl:copy>
<xsl:value-of select="." />
<xsl:value-of select='matches(.,".*[0-9]\{4\}-[0-9]\{2\}.*:[0-9]\{2\}*")'/>
<xsl:value-of select='replace(., "s/.*[0-9]\{4\}-[0-9]\{2\}.*:[0-9]\{2\}\(\.[0-9]*\).*/\1","")'/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
저는 실제로 XSLT에 익숙하지 않고이 특정 문제에 대해서만 사용해야합니다. 사전
이것이 효과적입니다. 내 테스터에서는 훌륭하지만 어플라이언스에서 사용하려고하면 오류가 발생합니다. 내 추측은 다른 XML 파서입니다 : –
내 추측은 다른 XML 파서입니다. 오류가 발생했습니다 : 오류 : '구문 오류'* [안 (*) 및. castable as xs : dateTime] '.' 치명적인 오류 : 'com.sun.org.apache.xalan.internal.xsltc.compiler.NotCall은 com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern' 으로 전송할 수 없습니다. com.sun. org.apache.xalan.internal.xsltc.compiler.NotCall은 com.sun.org.apache.xalan.internal.xsltc.compiler.Pattern으로 캐스팅 할 수 없습니다. 다른 매치 패턴을 시도 할 가능성은? –
Java 환경에서 XSLT 2.0을 사용하려면 Saxon 9에서 Saxon 9를 사용해야하며 Xalan은 XSLT 1.0 프로세서이고'xs : dateTime '데이터 형식이나 XPath 2.0'castable as'표현식도 지원하지도 않습니다. 'format-dateTime'이나 당신이 사용하려고했던'matches' 나'replace' 함수가 아닙니다. –