943,926 Members | Top Members by Rank

Ad:
Dec 10th, 2008
0

How to get exact xml file name

Expand Post »
Hi,

************************************************
Below is my xml code

<?xml version="1.0" encoding="UTF-8"?>
<concept><title>TEST</title><body><title>CHECKING</title></body></concept>
************************************************
Below is my xslt code

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">

<xsl:template match="/">
	<xsl:for-each select="concept">
		<xsl:variable name="filename1"><xsl:value-of select="base-uri()" /></xsl:variable>
		<xsl:value-of select="$filename1" />
	</xsl:for-each>
</xsl:template>

</xsl:stylesheet>
************************************************
Getting output
D:\test\Checking.dita

Instead of this it should display only
"Checking"
************************************************

Scenario

1] I need file name to generate the HTML file.
2] Level of folder may vary. [File should be in any folder on drive.]

Please suggest.

Cheers,
Mahesh
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mlohokare is offline Offline
22 posts
since Oct 2008
Dec 10th, 2008
0

Re: How to get exact xml file name

Hi Everybody,

I tried lot and finally get the solution for the same.

Which give the exact name of file.
Also it full fills the my condition
1] Level of folder may vary. [File should be in any folder on drive.]

please see modified code below...

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">


<xsl:template match="/">
<xsl:text><![CDATA[
]]>
</xsl:text>
<test><xsl:text><![CDATA[
	]]>
</xsl:text>
<xsl:for-each select="concept">
		<xsl:variable name="filename1"><xsl:value-of select="base-uri()" /></xsl:variable>
		<p><xsl:call-template name="name">
				<xsl:with-param name="id"><xsl:value-of select="$filename1" /></xsl:with-param>
			</xsl:call-template>
		</p>
	</xsl:for-each>
<xsl:text><![CDATA[
]]></xsl:text>
</test>
</xsl:template>

<xsl:template name="name">
	<xsl:param name="id" />
	<xsl:choose>
		<xsl:when test="$id[contains(.,'\')]">
			<xsl:call-template name="name"><xsl:with-param name="id"><xsl:value-of select="substring-after($id, '\')" /></xsl:with-param></xsl:call-template>
		</xsl:when>
		<xsl:otherwise>
			<xsl:value-of select="substring-before($id, '.')" />
		</xsl:otherwise>
	</xsl:choose>

</xsl:template>
</xsl:stylesheet>

If anyone has another idea on this please suggest.

Thanks.



Cheers,
Mahesh
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mlohokare is offline Offline
22 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in XML, XSLT and XPATH Forum Timeline: Merged Outlook contacts give too many duplicates
Next Thread in XML, XSLT and XPATH Forum Timeline: Retrieve XML in HTML ?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC