日期格式的XSLT转换[2100-10-10T23:59:59.000Z];添加GMT时区



我是XSLT变换的新手,面对XSLT变换的问题。

<?xml version="1.0" encoding="UTF-8"?>
<parent>
<headers>
    <status>Success</status>
    <requestTime>2017-10-10T23:59:59.000Z</requestTime>
    <Date>2500-10-10T23:59:59.000Z</Date>
</headers>
<results>
    <partyId></partyId>
    <contId></contId>
    <identifier>
        <number>987651435</number>
        <type>SSN</type>
        <status>PRIMARY</status>
        <expiryDate>2100-10-10T23:59:59.000Z</expiryDate>
    </identifier>
    <identifier>
        <number>123456789</number>
        <type>CL</type>
        <status>SECONDARY</status>
        <expiryDate>2100-10-10T10:00:59.000Z</expiryDate>
    </identifier>
    <address>
        <street>Anantha Nagar Phase 2</street>
        <city>Bangalore</city>
        <country>
            <code>IN</code>
        </country>
        <state>
            <code>KA</code>
        </state>
    </address>
    <officerNo>7654345</officerNo>
    <entityCode>005</entityCode>
    <birthDate>1991-12-13T01:01:00.000Z</birthDate>
</results>

我要转换所有标签,其值与所提供日期的正则符号模式相匹配,并添加时区即 00:00,而不是z。

您可以提供上述任何输入。

这可能会有所帮助。您将必须弄清楚您想要在XML中指定的时区值与日期相关。

未指定。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt">
<xsl:output method="xml" omit-xml-declaration="yes" version="1.0" encoding="UTF-8" />
  <!-- To match the date pattern, key off of some of the constants in the date string. 
       (The below match uses only some of the constants.)
  -->
  <xsl:template match="*[substring(.,5,1)='-' and substring(.,8,1)='-'  and substring(.,14,1)=':']">
    <xsl:copy>
      <!-- Do transform here. Below is an example. -->
      <xsl:value-of select="concat(substring-before(.,'Z'), '+00:00')"/>
    </xsl:copy>
  </xsl:template>
  <!-- Identity template. -->
  <xsl:template match="node()|@*">
    <xsl:copy>
      <xsl:apply-templates select="node()|@*"/>
    </xsl:copy>
  </xsl:template>
</xsl:stylesheet>

相关内容

  • 没有找到相关文章

最新更新