Reputation: 3351
I've the below XML.
<?xml version="1.0" encoding="UTF-8"?>
<entry>
<file name="FILE_ORD_01.xml"/>
<file name="FILE_ORD_02.xml"/>
<file name="FILE_ORD_03.xml"/>
<file name="FILE_ORD_04.xml"/>
<file name="FILE_ORD_05.xml"/>
</entry>
Basically this is a list of files in my folder In every XML file there is a phrase.
and I've another XML file from where i need to get the phrase
values compare them with the phrase values in this list and give in which list is this phrase
present in.
<xsl:variable name="prent">
<xsl:for-each select="document('C:\Users\u0138039\Desktop\Proview\MY\2015\title.xml')/entry/file">
<xsl:value-of select="normalize-space(document(concat('C:\Users\u0138039\Desktop\Proview\MY\2015\',./@name))/chapter[//page/@num=regex-group(1)])"/>
</xsl:for-each>
</xsl:variable>
using this code i'm able to see in which file is the phrase match found in for example if the match is found in FILE_ORD_03.xml
i want to print FILE_ORD_03
Here basically i want to get the file name in which the phrase is present in from the above list and print its value. by using base-uri()
or getting the attribute value directly
Thanks
Upvotes: 0
Views: 219
Reputation: 167716
I don't think you can extract the value from your variable as there you have simply text nodes with the normalized string value, but I think you want something along the lines of
<xsl:variable name="file-names" as="xs:string*"
select="document(document('file:///C:/Users/u0138039/Desktop/Proview/MY/2015/title.xml')/entry/file/@name)/chapter[//page/@name = regex-group(1)]/substring-before(tokenize(document-uri(/), '/')[last()], '.')"/>
to extract the file name(s) of matching file(s) as a sequence of strings into a second variable.
Upvotes: 1