2017-10-09 1 views
0

modtime이 더 크고 특정 값을 가진 객체가 포함되어 있으면 xml 메시지를 테스트해야합니다. 현재 테스트 할 xml의 모든 경로를 명시 적으로 나열한 하나의 스타일 시트를 사용합니다.XSLT는 모든 하위 값을 테스트합니다.

<xsl:if test="(translate(proot_modtime,'-T:Z','')>=translate('2017-09-30T00:00:45','-T:Z','')) 
     or (translate(a/a/pa_modtime,'-T:Z','')>=translate('2017-09-30T00:00:45','-T:Z','')) 
     or (translate(b/b/pb_modtime,'-T:Z','')>=translate('2017-09-30T00:00:45','-T:Z','')) 
     "> 
    <xsl:copy> 
    <xsl:copy-of select="./@*"/> 
    <xsl:apply-templates/> 
    </xsl:copy> 
</xsl:if> 

xml 메시지가 변경되면 스타일 시트를 업데이트하는 것을 잊어 버리는 경향이 있습니다. 그래서 나는 좀 더 일반적인 옵션을 요구하고있다. 모든 자식 노드를 찾습니다.이 노드에는 modtime이라는 단어가 포함되어 있으며 모두 확인해야합니다. 난 단지 첫 번째 * _modtime 노드를 테스트합니다 모든 Modtime - 노드

<xsl:if test="(translate(//*[ends-with(name(), '_modtime')],'-T:Z','')>=translate('2017-09-30T00:00:45','-T:Z',''))">  <xsl:copy> 
    <xsl:copy-of select="./@*"/> 
    <xsl:apply-templates/> 
    </xsl:copy> 
</xsl:if> 

에게 불행하게도 위의 코드를 일치 XPath 표현식을 사용하려고하고 다른 모든를 무시합니다. 사실 내가 테스트 할 모든

누군가가 XSL에 다음을 설명하기 위해, 어떤 생각을 가지고 있습니까 :

예 "XML 트리의 모든 modtime 노드 X 다음 값이 더 포함되어있는 경우, 전체 XML을 복사" XML :

<root> 
    <proot_modtime>2017-09-28T00:00:00</proot_modtime> 
    <a> 
    <a> 
     <pa_modtime>2017-10-01T16:15:15</pa_modtime> 
    </a> 
    </a> 
    <b> 
    <b> 
     <pb_modtime>2017-09-30T00:00:00</pb_modtime> 
    </b> 
    </b> 
</root> 

전체 XSL :

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> 
    <xsl:output method="xml" omit-xml-declaration="yes" indent="no"/> 
    <xsl:template match="root"> 
    <xsl:if test="(translate(//*[ends-with(name(), '_modtime')],'-T:Z','')>=translate('2017-09-30T00:00:45','-T:Z',''))"> 
     <xsl:copy> 
     <xsl:copy-of select="./@*"/> 
     <xsl:apply-templates/> 
     </xsl:copy> 
    </xsl:if> 
    </xsl:template> 
    <xsl:template match="*"> 
    <xsl:copy> 
     <xsl:copy-of select="./@*"/> 
     <xsl:apply-templates/> 
    </xsl:copy> 
    </xsl:template> 
</xsl:stylesheet> 
+0

* 전체 XML *을 복사 하시겠습니까? 전체 XML 문서 또는 노드 태그 만? 기준이 충족되지 않으면 어떻게됩니까? – Parfait

+0

xsl은 전체 메시지를 복사하거나 빈 문자열로 변환합니다. modtime tejoe

+0

다시, * message *는 무엇을 의미합니까? 전체 XML 문서? ''모두? – Parfait

답변

0

난 당신이 단순히

012을 원한다고 생각
<xsl:if test="//*[ends-with(name(), '_modtime')][translate(.,'-T:Z','')>=translate('2017-09-30T00:00:45','-T:Z','')]">