Это мой вклад XML:Как применить несколько шаблонов в XSLT?
<root xmlns:og="http://www.example.com" xmlns:dc="http://www.example.com" >
<hits>
<hits>
<_index>indexname</_index>
<_type>indextype</_type>
<_source>
<keywords>keywords-NOT-PROVIDED</keywords>
<secureFlag>false</secureFlag>
<description>How do you make sure your search and big data applications are well-maintained? How to free IT staff's time to focus more on business goals? Watch our expert address the top 5 managed services questions asked by customers.</description>
<connectorSpecific>
<discoveredBy>http://www.example.com/enterprise-search-case-studies</discoveredBy>
<xslt>false</xslt>
<pathFromSeed>LL</pathFromSeed>
<md5>WVBM5NDACLWRN4OSXRCQUA5RJA</md5>
</connectorSpecific>
<title>Do I Need Managed Services for My Search and Big Data Applications?</title>
<url>http://www.example.com/big-data-search-managed-services-questions</url>
<UD>http://www.example.com/big-data-search-managed-services-questions</UD>
<size>21467</size>
<displayurl>http://www.example.com/big-data-search-managed-services-questions</displayurl>
<UE>http://www.example.com/big-data-search-managed-services-questions</UE>
<submitTime>2016-07-21T22:55:00+0000</submitTime>
<newContent>Site Map Terms, privacy and cookie</newContent>
<T>Do I Need Managed Services for My Search and Big Data Applications?</T>
<sourceType>heritrix</sourceType><U>http://www.example.com/big-data-search-managed-services-questions</U>
<sourceName>PIB</sourceName>
</_source>
<_id>http://www.example.com/big-data-search-managed-services-questions</_id>
<_score>1</_score>
</hits>
<hits>
</root>
Это XSLT, что я подаю:
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<xsl:template match="/">
<GSP>
<xsl:attribute name="VER">
<xsl:value-of select="3.2" />
</xsl:attribute>
<xsl:for-each select="root">
<TM>
<xsl:value-of select="(floor(took) div floor(1000))" />
</TM>
<RES>
<M>
<xsl:value-of select="floor(hits/total)" />
</M>
<xsl:for-each select="hits/hits">
<xsl:variable name="var1_resultof_first" as="node()"
select="_source" />
<R>
<xsl:attribute name="N">
<xsl:number format="0" level="single" />
</xsl:attribute>
<U>
<xsl:sequence
select="xs:string(xs:anyURI(fn:string($var1_resultof_first/url)))" />
</U>
<UE>
<xsl:sequence
select="xs:string(xs:anyURI(fn:string($var1_resultof_first/url)))" />
</UE>
<UD>
<xsl:sequence
select="xs:string(xs:anyURI(fn:string($var1_resultof_first/url)))" />
</UD>
<T>
<xsl:choose>
<xsl:when test="highlight/T">
<xsl:for-each select="highlight/T">
<xsl:sequence select="fn:string(.)" />
</xsl:for-each>
</xsl:when>
<xsl:when test="fn:string($var1_resultof_first/T)">
<xsl:sequence select="fn:string($var1_resultof_first/T)" />
</xsl:when>
<xsl:otherwise>
<xsl:sequence
select="xs:string(xs:anyURI(fn:string($var1_resultof_first/url)))" />
</xsl:otherwise>
</xsl:choose>
</T>
<!-- <T> <xsl:sequence select="fn:string($var1_resultof_first/T)"
/> </T> -->
<S>
<xsl:for-each select="highlight">
<b>... </b>
<xsl:sequence select="fn:string(.)" />
<b> ...</b>
</xsl:for-each>
</S>
<CRAWLDATE>
<xsl:value-of select="substring-before(_source/submitTime,'T')" />
</CRAWLDATE>
</R>
</xsl:for-each>
</RES>
</xsl:for-each>
</GSP>
</xsl:template>
</xsl:stylesheet>
Вы можете увидеть элемент размера в моем входном XML.
<size>21467</size>
Я хочу, чтобы применить этот шаблон для моего размера элемента (шаблон размера)
<xsl:template match="size">
<HAS>
<C SZ="{format-number(. div 1000, '0k')}"/>
</HAS>
</xsl:template>
Я новичок в XSLT и не использовать несколько шаблонов в XSLT. Где я должен поместить свой шаблон размера в свой оригинальный XSLT, чтобы его можно было применить к параметру размера? Любая помощь будет оценена по достоинству.
Где на выходе вы хотите? –