I've the below 2 XML Files.
Title.XML
<?xml version="1.0" encoding="UTF-8"?>
<entry>
<file name="LCCPMY_CH_01.xml"></file>
</entry>
Contents.xml
and the content of
LCCPMY_CH_01.xml is as below.
Code:
<chapter num="A">
<section level="sect1">
<page num="1"/>
<title>
<content-style font-style="bold">Chapter 1: This is Chapter</content-style>
</title>
</section>
</chapter>
here what i'm trying to do is from Content.xml file, by using the help of Title.xml file, i'm trying to match the number(page num of LCCPMY_CH_01.xml is equal to Contents.xml toc-pg value). I'm using the below XSLT to do it.
Code:
<xsl:template match="toc-pg" mode="x">
<xsl:variable name="dot" select="."/>
<xsl:analyze-string select="." regex="([0-9]+)">
<xsl:matching-substring>
<xsl:variable name="prent">
<xsl:for-each select="document('C:\Users\u0138039\Desktop\Proview\MY\2014\The Law of Costs in Civil Proceedings\title.xml')/entry/file">
<xsl:value-of select="normalize-space(document(concat('C:\Users\u0138039\Desktop\Proview\MY\2014\The Law of Costs in Civil Proceedings\',./@name))/chapter/section[@level='sect1']/substring-after(fn:substring-before(.,':'),' ')[//page/@num=$dot]|a[//page/@num=$dot])"/>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="cha">
<xsl:value-of select="$prent"/>
</xsl:variable>
<xsl:variable name="size">
<xsl:value-of select="string-length($cha)"/>
</xsl:variable>
<xsl:variable name="conct">
<xsl:choose>
<xsl:when test="$size>'1'">
<xsl:value-of select="concat('er:#LCCPMY_CH_',$cha,'/pg_',.)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('er:#LCCPMY_CH_0',$cha,'/pg_',.)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<a href="{$conct}">
<xsl:value-of select="regex-group(1)"/>
</a>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="."/>
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>
but when i'm running this I'm getting the below Exception.
Code:
XSLT 2.0 Debugging Error: Error: file:///C:/Users/u0138039/Desktop/Proview/MY/2014/The%20Law%20of%20Costs%20in%20Civil%20Proceedings/09172014/XSLT/MCCL_TOC_01.xsl:235: Not a node item - item has type xs:string with value '1' - Details: - XPTY0020: The context item in an axis step must be a node
please let me know where am i going wrong and how can i fix this. I use XSLT 2.0.
The error is thrown here
Code:
<xsl:value-of select="normalize-space(document(concat('C:\Users\u0138039\Desktop\Proview\MY\2014\The Law of Costs in Civil Proceedings\',./@name))/chapter/section[@level='sect1']/substring-after(fn:substring-before(.,':'),' ')[//page/@num=.]|a[//page/@num=.])"/>
Thanks