I would like to use node-set() in Antenna House so I can access preceding-siblings in a sorted list. (I'm trying to follow this example: [using preceding-sibling with with xsl:sort)
I'm not sure what the syntax is for declaring the namespace to access node-set(). AH is not giving any errors, but my call to node-set() fails. I've tried:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:msxsl="urn:schemas-microsoft-com:xslt" extension-element-prefixes="msxsl" version="1.0">
Here is the XML:
<illustratedPartsCatalog>
<figure id="fig1">...</figure>
<catalogSeqNumber assyCode="00" figureNumber="01" indenture="0" item="000" itemVariant="A" subSubSystemCode="0" subSystemCode="0" systemCode="00">
<itemSeqNumber itemSeqNumberValue="000">
<quantityPerNextHigherAssy>XX</quantityPerNextHigherAssy>
<partRef manufacturerCodeValue="00000" partNumberValue="11111-111">
</partRef>
<partSegment>
<itemIdentData>
<descrForPart>VALVE ASSEMBLY</descrForPart></itemIdentData>
</partSegment><applicabilitySegment><usableOnCodeAssy>X</usableOnCodeAssy>
</applicabilitySegment></itemSeqNumber></catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<figure id="fig2">...</figure>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
<catalogSeqNumber>...</catalogSeqNumber>
</illustratedPartsCatalog>
XSLT:
<xsl:variable name="sortedCSN">
<xsl:for-each select="illustratedPartsCatalog/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:copy-of select="." />
</xsl:for-each>
</xsl:variable>
<xsl:template name="SortParts2" >
<xsl:for-each select="msxsl:node-set($sortedCSN)/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:call-template name="catalogSeqNumber-NI">
<xsl:with-param name="figNo" select="concat(#figureNumber,#figureNumberVariant)"/>
<xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/#figureNumber,preceding-sibling::catalogSeqNumber/#figureNumberVariant)" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="catalogSeqNumber-NI">
<xsl:param name="figNo"/>
<xsl:param name="prfigNo" />
<fo:table-row keep-together.within-page="always" wrap-option="wrap">
<fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-transform="uppercase" wrap-option="wrap">
<fo:block wrap-option="wrap">
<xsl:value-of select=" ./itemSeqNumber/partRef/#partNumberValue"/>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-align="start">
<xsl:choose>
<xsl:when test="$figNo">
<fo:block>
<xsl:text> </xsl:text><xsl:value-of select="$figNo"/><xsl:text> </xsl:text> <xsl:value-of select="$prfigNo"/>
</fo:block>
</xsl:when>
<xsl:otherwise>
<fo:block />
</xsl:otherwise>
</xsl:choose>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding" text-align="start">
<fo:block>
<xsl:if test="./itemSeqNumber/partLocationSegment/notIllustrated">
<xsl:text>-</xsl:text>
</xsl:if>
<xsl:choose>
<xsl:when test="#item">
<xsl:variable name="itemNo">
<xsl:call-template name="suppressZero" >
<xsl:with-param name="pText" select="#item"/>
</xsl:call-template>
</xsl:variable>
<xsl:text> </xsl:text>
<xsl:value-of select="concat($itemNo,#itemVariant)"/>
</xsl:when>
<xsl:otherwise />
</xsl:choose>
</fo:block>
</fo:table-cell>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding">
<fo:block>
<xsl:value-of select="./itemSeqNumber/quantityPerNextHigherAssy"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:template>
I think the default for Antenna House on Windows is to use MSXML so the attempt with xmlns:msxsl="urn:schemas-microsoft-com:xslt" is fine as far as using the node-set extension function.
I think you simply need to change the XSLT to
<xsl:variable name="sortedCSN">
<xsl:for-each select="illustratedPartsCatalog/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:copy-of select="." />
</xsl:for-each>
</xsl:variable>
<xsl:template name="SortParts2" >
<xsl:for-each select="msxsl:node-set($sortedCSN)/catalogSeqNumber">
<xsl:sort select="concat(itemSeqNumber/partRef/#partNumberValue, #figureNumber,#item)"/>
<xsl:call-template name="catalogSeqNumber-NI">
<xsl:with-param name="figNo" select="concat(#figureNumber,#figureNumberVariant)"/>
<xsl:with-param name="prfigNo" select="concat(preceding-sibling::catalogSeqNumber/#figureNumber,preceding-sibling::catalogSeqNumber/#figureNumberVariant)" />
</xsl:call-template>
</xsl:for-each>
</xsl:template>
to make sense with the input you have shown (as far as you have shown it, can't judge all those xsl:sort attempts without seeing the data to be sorted).
On the other hand, if you get errors about the stylesheet not being correct XSLT or XML, you would better show us a minimal but complete stylesheet allowing us to reproduce the problem.
XML:
<levelledPara><title>Tools List and Tool Illustrations</title>
<levelledPara><title>General</title>
<levelledPara><para>The special tools, fixtures, and equipment needed.</para></levelledPara></levelledPara>
XSLT:
<xsl:template match="levelledPara" name="levelledPara" mode="tocdm">
<xsl:if test="*[self::title] and not(parent::*[self::levelledPara])">
<xsl:variable name="id">
<xsl:call-template name="para.id"/>
</xsl:variable>
<fo:table-row>
<fo:table-cell xsl:use-attribute-sets="table.cell.padding1" number-columns-spanned="2">
<fo:block text-transform="capitalize" text-align-last="justify" text-indent="21mm">
<xsl:number count="levelledPara" from="content" level="multiple" format="1.1.1.1.1"/>
<xsl:text> </xsl:text>
<xsl:value-of select="title" /><fo:leader leader-pattern="dots"/><fo:basic-link internal-destination="{$id}"><fo:page-number-citation ref-id="{$id}"/></fo:basic-link>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
</xsl:template>
<xsl:template match="levelledPara">
<fo:list-block
provisional-distance-between-starts="21mm"
provisional-label-separation="4pt">
<fo:list-item space-after="8pt" space-before="13pt" start-indent="0pt">
<xsl:variable name="id">
<xsl:if test="*[self::title] and not(parent::*[self::levelledPara])">
<xsl:call-template name="para.id"/>
</xsl:if>
</xsl:variable>
<fo:list-item-label
end-indent="label-end()"
text-align="start">
<fo:block font-weight="bold" id="{$id}">
<xsl:if test="not(./table)">
<xsl:number count="levelledPara" from="content" level="multiple" format="1.1.1.1.1"/>
</xsl:if>
</fo:block>
</fo:list-item-label>
<fo:list-item-body
start-indent="body-start()">
<xsl:apply-templates/>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
<xsl:template name="para.id">
<xsl:param name="object" select="."/>
<xsl:apply-templates select="ancestor::dmodule/identAndStatusSection/dmAddress/dmIdent/dmCode"/>
<xsl:choose>
<xsl:when test="$object/#id">
<xsl:value-of select="$object/#id"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(count(ancestor::node()),'00000000',count(preceding::node()))"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The first titled levelledPara should be included in the Table of Contents. In my sample markup none have IDs. The page number wasn't resolving because I forgot to assign an id to the fo:block for levelledPara.
You've shown the XSLT for the table of contents. The ID in the TOC should match an ID in the main text of your document.
So the template match="levelledPara" should contain a block that sets the ID:
<xsl:variable name="lpcode"><xsl:value-of select="$dmcode" /><xsl:value-of select="generate-id(.)" /></xsl:variable>
<fo:block id="{$lpcode}">
I'm using Apache FOP to generate PDFs from my web application, where users can edit richtext using CKEditor.
My problem is that users sometimes use different levels of indentation in (un-)ordered lists, e.g.:
List item level 1
List item level 2
The CKEditor shows different bulletins per level (or indentation), but the generated PDFs do not, because my template looks like this:
<!-- Lists -->
<xsl:template match="ul|ol" mode="content">
<xsl:apply-templates select="li" mode="content">
<xsl:with-param name="ordered">
<xsl:value-of select="name()='ol'"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="li" mode="content">
<xsl:param name="ordered"/>
<xsl:variable name="label">
<xsl:choose>
<xsl:when test="$ordered='true'">
<xsl:value-of select="position()"/>
.
</xsl:when>
<xsl:otherwise>
•
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:list-block padding-bottom="0pt">
<fo:list-item>
<fo:list-item-label>
<fo:block>
<xsl:value-of select="$label"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates mode="content"/>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
So how can I set the label variable depending on which level of indentation I'm at?
Something like:
1st level: •
2nd level: ◦
3rd level: ⁍
Thanks in advance, ~Fabi
EDIT: So the solution suggested by #fafl looks like this:
<!-- Lists -->
<xsl:template match="ul|ol" mode="content">
<xsl:param name="depth" select="0"/>
<xsl:apply-templates select="li" mode="content">
<xsl:with-param name="ordered">
<xsl:value-of select="name()='ol'"/>
</xsl:with-param>
<xsl:with-param name="depth">
<xsl:value-of select="$depth + 1"/>
</xsl:with-param>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="li" mode="content">
<xsl:param name="depth" select="0"/>
<xsl:param name="ordered"/>
<xsl:variable name="label">
<xsl:choose>
<xsl:when test="$ordered='true'">
<xsl:value-of select="position()"/>
.
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$depth = 1">
• <!--filled circle-->
</xsl:when>
<xsl:when test="$depth = 2">
◦ <!--not-filled circle-->
</xsl:when>
<xsl:otherwise>
■ <!--black square -->
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<fo:list-block padding-bottom="0pt">
<fo:list-item>
<fo:list-item-label>
<fo:block>
<xsl:value-of select="$label"/>
</fo:block>
</fo:list-item-label>
<fo:list-item-body start-indent="body-start()">
<fo:block>
<xsl:apply-templates mode="content">
<xsl:with-param name="depth">
<xsl:value-of select="$depth"/>
</xsl:with-param>
</xsl:apply-templates>
</fo:block>
</fo:list-item-body>
</fo:list-item>
</fo:list-block>
</xsl:template>
Try adding a parameter "depth" to both templates with a default value of 1. On each recursive call of "ul|ol" increase it by 1. Then you can query it inside both templates.
hi we have requirement to group our maturity date based on the our logical group reference.
<xsl:for-each select="OutboundPayment[count(. | key('contacts-by-LogicalGroupReference', PaymentNumber/LogicalGroupReference/)[1]) = 1]">
I am not able to understand the above for each statement. If i try to concat my maturity date with for each. my xml out put is getting in to null
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Header: IBY_SEPA_STR_REM.xsl 120.7.12020000.3 2012/10/23 10:03:59 asarada ship $ -->
<!-- dbdrv: exec java oracle/apps/xdo/oa/util XDOLoader.class java &phase=dat checkfile:~PROD:patch/115/publisher/templates:IBY_SEPA_STR_REM.xsl UPLOAD -DB_USERNAME &un_apps -DB_PASSWORD &pw_apps -JDBC_CONNECTION &jdbc_db_addr -LOB_TYPE TEMPLATE -APPS_SHORT_NAME IBY -LOB_CODE IBY_SEPA_CREDIT_INIT_TEMPLATE_STR_REM -LANGUAGE en -XDO_FILE_TYPE XSL-XML -FILE_NAME &fullpath:~PROD:patch/115/publisher/templates:IBY_SEPA_STR_REM.xsl -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="no"/>
<xsl:output method="xml"/>
<xsl:key name="contacts-by-LogicalGroupReference" match="OutboundPayment" use="PaymentNumber/LogicalGroupReference" />
<xsl:template match="OutboundPaymentInstruction">
<Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:variable name="instrid" select="PaymentInstructionInfo/InstructionReferenceNumber"/>
<CstmrCdtTrfInitn>
<GrpHdr>
<MsgId>
<xsl:value-of select="$instrid"/>
</MsgId>
<CreDtTm>
<xsl:value-of select="PaymentInstructionInfo/InstructionCreationDate"/>
</CreDtTm>
<NbOfTxs>
<xsl:value-of select="InstructionTotals/PaymentCount"/>
</NbOfTxs>
<CtrlSum>
<xsl:value-of select="format-number(InstructionTotals/TotalPaymentAmount/Value,'0.00')"/>
</CtrlSum >
<InitgPty>
<Nm>
<xsl:value-of select="InstructionGrouping/Payer/Name"/>
</Nm>
</InitgPty>
</GrpHdr>
<xsl:for-each select="OutboundPayment[count(. | key('contacts-by-LogicalGroupReference', PaymentNumber/LogicalGroupReference/)[1]) = 1]">
<xsl:sort select="PaymentNumber/LogicalGroupReference" />
<PmtInf>
<PmtInfId>
<xsl:value-of select="PaymentNumber/LogicalGroupReference"/>
</PmtInfId>
<PmtMtd>TRF</PmtMtd>
<NbOfTxs>
<xsl:value-of select="count(key('contacts-by-LogicalGroupReference', PaymentNumber/LogicalGroupReference))"/>
</NbOfTxs>
<CtrlSum>
<xsl:value-of select="format-number(sum(key('contacts-by-LogicalGroupReference', PaymentNumber/LogicalGroupReference)/PaymentAmount/Value),'0.00')"/>
</CtrlSum>
<PmtTpInf>
<InstrPrty>NORM</InstrPrty>
<SvcLvl>
<Cd>SEPA</Cd>
</SvcLvl>
<LclInstrm>
<Cd>CONF</Cd>
</LclInstrm>
<CtgyPurp><Cd>SUPP</Cd></CtgyPurp>
</PmtTpInf>
<ReqdExctnDt>
<xsl:value-of select="MaturityDate"/> <!-- PaymentDate, PaymentDueDate, MaturityDate-->
</ReqdExctnDt>
<Dbtr>
<Nm>
<xsl:value-of select="Payer/Name"/>
</Nm>
<PstlAdr>
<StrtNm>
<xsl:value-of select="Payer/Address/AddressLine1"/>
</StrtNm>
<PstCd>
<xsl:value-of select="Payer/Address/PostalCode"/>
</PstCd>
<TwnNm>
<xsl:value-of select="Payer/Address/City"/>
</TwnNm>
<xsl:if test="not(Payer/Address/State='')">
<CtrySubDvsn>
<xsl:value-of select="Payer/Address/State"/>
</CtrySubDvsn>
</xsl:if>
<Ctry>
<xsl:value-of select="Payer/Address/Country"/>
</Ctry>
</PstlAdr>
<Id>
<OrgId>
<xsl:choose>
<xsl:when test="not(Payer/TaxRegistrationNumber='')">
<Othr><Id><xsl:value-of select="Payer/TaxRegistrationNumber"/></Id></Othr>
</xsl:when>
<xsl:otherwise>
<Othr><Id><xsl:value-of select="Payer/LegalEntityRegistrationNumber"/></Id></Othr>
</xsl:otherwise>
</xsl:choose>
</OrgId>
</Id>
</Dbtr>
<DbtrAcct>
<Id>
<IBAN>
<xsl:value-of select="BankAccount/IBANNumber"/>
</IBAN>
</Id>
<Ccy>
<xsl:value-of select="BankAccount/BankAccountCurrency/Code"/>
</Ccy>
</DbtrAcct>
<DbtrAgt>
<FinInstnId>
<BIC>
<xsl:value-of select="BankAccount/SwiftCode"/>
</BIC>
<PstlAdr>
<Ctry>ES</Ctry>
</PstlAdr>
</FinInstnId>
</DbtrAgt>
<xsl:for-each select="key('contacts-by-LogicalGroupReference', PaymentNumber/LogicalGroupReference)">
<CdtTrfTxInf>
<xsl:variable name="paymentdetails" select="PaymentDetails"/>
<PmtId>
<InstrId>
<xsl:value-of select="PaymentNumber/PaymentReferenceNumber"/>
</InstrId>
<EndToEndId>
<xsl:value-of select="PaymentNumber/PaymentReferenceNumber"/>
</EndToEndId>
</PmtId>
<Amt>
<InstdAmt>
<xsl:attribute name="Ccy">
<xsl:value-of select="PaymentAmount/Currency/Code"/>
</xsl:attribute>
<xsl:value-of select="format-number(PaymentAmount/Value,'0.00')"/>
</InstdAmt>
</Amt>
<CdtrAgt>
<FinInstnId>
<BIC>
<xsl:value-of select="PayeeBankAccount/SwiftCode"/>
</BIC>
<PstlAdr>
<Ctry>ES</Ctry>
</PstlAdr>
</FinInstnId>
</CdtrAgt>
<Cdtr>
<Nm>
<xsl:value-of select="Payee/Name"/>
</Nm>
<PstlAdr>
<StrtNm>
<xsl:value-of select="Payee/Address/AddressLine1"/>
</StrtNm>
<PstCd>
<xsl:value-of select="Payee/Address/PostalCode"/>
</PstCd>
<TwnNm>
<xsl:value-of select="Payee/Address/City"/>
</TwnNm>
<xsl:if test="not(Payee/Address/State='')">
<CtrySubDvsn>
<xsl:value-of select="Payee/Address/State"/>
</CtrySubDvsn>
</xsl:if>
<Ctry>
<xsl:value-of select="Payee/Address/Country"/>
</Ctry>
</PstlAdr>
<Id>
<OrgId>
<xsl:if test="not(Payee/TaxRegistrationNumber='')">
<Othr><Id><xsl:value-of select="Payee/TaxRegistrationNumber"/></Id></Othr>
</xsl:if>
<xsl:if test="(Payee/TaxRegistrationNumber='')">
<xsl:if test="not(Payee/LegalEntityRegistrationNumber='')">
<Othr><Id><xsl:value-of select="Payee/LegalEntityRegistrationNumber"/></Id></Othr>
</xsl:if>
<xsl:if test="(Payee/LegalEntityRegistrationNumber='')">
<xsl:if test="not(Payee/SupplierNumber='')">
<Othr><Id><xsl:value-of select="Payee/SupplierNumber"/></Id></Othr>
</xsl:if>
<xsl:if test="(Payee/SupplierNumber='')">
<xsl:if test="not(Payee/PartyNumber='')">
<Othr><Id><xsl:value-of select="Payee/SupplierNumber"/></Id></Othr>
</xsl:if>
<xsl:if test="(Payee/PartyNumber='')">
<Othr><Id><xsl:value-of select="Payee/SupplierNumber"/></Id></Othr>
</xsl:if>
</xsl:if>
</xsl:if>
</xsl:if>
</OrgId>
</Id>
<xsl:if test="not(Payee/ContactInfo/ContactLocators/EmailAddress='')">
<CtctDtls>
<EmailAdr><xsl:value-of select="Payee/ContactInfo/ContactLocators/EmailAddress"/></EmailAdr>
</CtctDtls>
</xsl:if>
</Cdtr>
<CdtrAcct>
<Id>
<IBAN>
<xsl:value-of select="PayeeBankAccount/IBANNumber"/>
</IBAN>
</Id>
</CdtrAcct>
<RmtInf>
<xsl:variable name="IssurName" select="Payee/Name"/>
<xsl:for-each select="DocumentPayable">
<Strd>
<RfrdDocInf>
<Tp>
<CdOrPrtry>
<Cd>
<xsl:choose>
<xsl:when test="TotalDocumentAmount/Value >= 0">
<xsl:text>CINV</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>CREN</xsl:text>
</xsl:otherwise>
</xsl:choose>
</Cd>
</CdOrPrtry>
</Tp>
<Nb>
<xsl:value-of select="DocumentNumber/ReferenceNumber"/>
</Nb>
<RltdDt>
<xsl:value-of select="DocumentDate"/>
</RltdDt>
</RfrdDocInf>
<RfrdDocAmt>
<xsl:choose>
<xsl:when test="TotalDocumentAmount/Value >= 0">
<DuePyblAmt>
<xsl:attribute name="Ccy">
<xsl:value-of select="TotalDocumentAmount/Currency/Code"/>
</xsl:attribute>
<xsl:value-of select="format-number(TotalDocumentAmount/Value,'0.00')"/>
</DuePyblAmt>
</xsl:when>
<xsl:otherwise>
<CdtNoteAmt>
<xsl:attribute name="Ccy">
<xsl:value-of select="TotalDocumentAmount/Currency/Code"/>
</xsl:attribute>
<xsl:value-of select="format-number((-1 * TotalDocumentAmount/Value),'0.00')"/>
</CdtNoteAmt>
</xsl:otherwise>
</xsl:choose>
</RfrdDocAmt>
</Strd>
</xsl:for-each>
</RmtInf>
</CdtTrfTxInf>
</xsl:for-each>
</PmtInf>
</xsl:for-each>
</CstmrCdtTrfInitn>
</Document>
</xsl:template>
</xsl:stylesheet>
Hi i'm having the below xml.
<primaryie>
<content-style font-style="bold">Administration</content-style>
</primaryie>
and when i'm applying the below xslt it is working fine.(the content-style part)
<xsl:template match="primaryie">
<div class="primaryie">
<xsl:apply-templates select="content-style"/>
<xsl:if test="contains(current()/text(), '.')">
<xsl:variable name="numberString" select="substring(current()/text(), string-length(substring-before(current()/text(),'.'))-1)"></xsl:variable>
<xsl:call-template name="numbersToLink">
<xsl:with-param name="numbersString" select="$numberString"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</div>
</xsl:template>
<xsl:template name="numbersToLink">
<xsl:param name="numbersString"></xsl:param>
<xsl:choose>
<xsl:when test="contains($numbersString, ',')">
<xsl:call-template name="splitByComma">
<xsl:with-param name="numString" select="$numbersString"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($numbersString, '-')">
<xsl:call-template name="splitByHyphen">
<xsl:with-param name="numString" select="$numbersString"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="5 >= string-length(normalize-space($numbersString))">
<xsl:variable name="x">
<xsl:value-of select="substring-after($numbersString,'.')"></xsl:value-of>
</xsl:variable>
<xsl:variable name="y">
<xsl:value-of select="normalize-space(substring-before($numbersString,'.'))"></xsl:value-of>
</xsl:variable>
<xsl:variable name="conca">
<xsl:value-of select="concat('er:#BVI_CH_0',$y,'/P',$y,'-',$x)"/>
</xsl:variable>
<a href="{$conca}">
<xsl:value-of select="$numbersString"/>
</a>
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template name="splitByComma">
<xsl:param name="numString"></xsl:param>
<xsl:choose>
<xsl:when test="contains(substring-before($numString,','), '-')">
<xsl:call-template name="splitByHyphen">
<xsl:with-param name="numString" select="$numString"/>
</xsl:call-template>
</xsl:when>
<xsl:when test="contains($numString,',')">
<xsl:variable name="abc">
<xsl:value-of select="normalize-space(substring-before($numString,'.'))"/>
</xsl:variable>
<xsl:variable name="def">
<xsl:value-of select="substring-before(substring-after($numString,'.'),',') "/>
</xsl:variable>
<xsl:variable name="conct">
<xsl:value-of select="concat('er:#BVI_CH_0',$abc,'/P',$abc,'-',$def)"/>
<!--"concat(concat('er:#BVI_CH_0',,'/P',$y,'-',$x)"/-->
</xsl:variable>
<a href="{$conct}">
<xsl:value-of select="substring-before($numString,',')"/>
</a>
<xsl:text>, </xsl:text>
<xsl:if test="contains(substring-after($numString,','), '.')">
<xsl:call-template name="numbersToLink">
<xsl:with-param name="numbersString" select="normalize-space(substring-after($numString,','))"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template name="splitByHyphen">
<xsl:param name="numString"></xsl:param>
<xsl:choose>
<xsl:when test="contains($numString,'-')">
<xsl:variable name="abc">
<xsl:value-of select="normalize-space(substring-before($numString,'.'))"/>
</xsl:variable>
<xsl:variable name="def">
<xsl:value-of select="substring-before(substring-after($numString,'.'),'-') "/>
</xsl:variable>
<xsl:variable name="conct">
<xsl:value-of select="concat('er:#BVI_CH_0',$abc,'/P',$abc,'-',$def)"/>
<!--"concat(concat('er:#BVI_CH_0',,'/P',$y,'-',$x)"/-->
</xsl:variable>
<a href="{$conct}">
<!--<xsl:value-of select="substring-before($numString,'-')"/>-->
<xsl:value-of select="substring-before($numString,'-')"/>
</a>
<xsl:text>–</xsl:text>
<xsl:if test="contains(substring-after($numString,'-'), '.')">
<xsl:call-template name="numbersToLink">
<xsl:with-param name="numbersString" select="normalize-space(substring-after($numString,'-'))"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
</xsl:choose>
</xsl:template>
but i have a special case in the same document as below xml states.
<primaryie>
<content-style font-style="bold">VIRRGIN system</content-style> 7.204, 7.205
</primaryie>
here when i'm applying the above template it is working with content-style, but i want it to work also with numberstolink template.
the outputs are as below.
current:
<div class="primaryie"><span class="font-style-bold">Virgin Islands Special Trust Act (VISTA) 9.077</span></div>
expexted:
<div class="primaryie"><span class="font-style-bold">Virgin Islands Special Trust Act (VISTA) 9.077</span></div>
Please change this below portion in your code
<xsl:template match="primaryie">
<div class="primaryie">
<xsl:apply-templates select="content-style"/>
<xsl:if test="contains(current(), '.')">
<xsl:variable name="numberString" select="substring(current(), string-length(substring-before(current(),'.'))-1)"></xsl:variable>
<xsl:call-template name="numbersToLink">
<xsl:with-param name="numbersString" select="$numberString"></xsl:with-param>
</xsl:call-template>
</xsl:if>
</div>
</xsl:template>
Use only Current() instead of Current()/Text()
Output for give XML is
<div class="primaryie">VIRRGIN system 7.204, 7.205</div>