tia_kamakshi
asked on
Reading another xml from xslt and append the exising
Hi Experts,
My xslt is running on some xml.
Now I need to create a node list (Its basically xml file) from my new xml file while reading from same xslt
I mean I need to read another xml below
and wants to create following output
It should create the nodes from template "DynamicPages"
Here is my sample xslt
Please help me do the needful
Regards
My xslt is running on some xml.
Now I need to create a node list (Its basically xml file) from my new xml file while reading from same xslt
I mean I need to read another xml below
<?xml version="1.0" encoding="UTF-8"?>
<minisitemaps>
<minimap name="news">
<location>about/News/News_SiteMap.aspx</location>
<lastmodified>hgfhfg</lastmodified>
<addpuburl>true</addpuburl>
</minimap>
<minimap name="FAQ">
<location>Help/faq/FAQ_SiteMap.aspx</location>
<lastmodified>jhkhkl</lastmodified>
<addpuburl>true</addpuburl>
</minimap>
</minisitemaps>
and wants to create following output
<sitemap>
<loc>
http://www.xyz.com/about/News/News_SiteMap.aspx
</loc>
<lastmod>
hgfhfg
</lastmod>
</sitemap>
<sitemap>
<loc>
http://www.xyz.com/Help/faq/FAQ_SiteMap.aspx
</loc>
<lastmod>
jhkhkl
</lastmod>
</sitemap>
It should create the nodes from template "DynamicPages"
<xsl:template match="??????" mode="DynamicPages">
Here is my sample xslt
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:utils="urn:XSLTExtensions" exclude-result-prefixes="utils">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no" />
<xsl:param name="hostPrefix">http://www.xyz.com</xsl:param>
<xsl:variable name="sitemap">/sitemap.xml</xsl:variable>
<xsl:variable name="minisitemap">/minisitemap.xml</xsl:variable>
<xsl:variable name="News_sitemap">/about/News/News_SiteMap.aspx</xsl:variable>
<xsl:variable name="FAQ_sitemap">/help/faqs/FAQ_SiteMap.aspx</xsl:variable>
<xsl:template match="/">
<sitemapindex xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd">
<xsl:variable name="modified" select="utils:FileModified($sitemap)" />
<xsl:if test="$modified != ''">
<sitemap>
<loc>
<xsl:value-of select="concat($hostPrefix, $sitemap)"/>
</loc>
<lastmod>
<xsl:value-of select="$modified"/>
</lastmod>
</sitemap>
</xsl:if>
<xsl:apply-templates select="/sitedata/region/site/language" mode="DynamicPages"/>
</sitemapindex>
</xsl:template>
<xsl:template match="??????" mode="DynamicPages">
<xsl:if test="$modified != ''">
<sitemap>
<loc>
<xsl:value-of select="concat($hostPrefix, @url, $location)"/>
</loc>
<lastmod>
<xsl:value-of select="$modified"/>
</lastmod>
</sitemap>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Please help me do the needful
Regards
ASKER
Many Thanks, it works great.
I wanted to put 'otherdocname' path in variable.
If otherdocname does not exists or otherdocname is blank then I do not wanted to call template
<xsl:apply-templates select="document('otherdoc name')" mode="DynamicPages"/>
Basically I wanted to make this generic. If document is passed in varaiable as parameter then tempplate should call else not
Please suggest
I wanted to put 'otherdocname' path in variable.
If otherdocname does not exists or otherdocname is blank then I do not wanted to call template
<xsl:apply-templates select="document('otherdoc
Basically I wanted to make this generic. If document is passed in varaiable as parameter then tempplate should call else not
Please suggest
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Many Many Thanks
welcome
<xsl:apply-templates select="document('otherdoc
All you need then is handling that seperate tree using the same mode
<xsl:template match="minisitemaps" mode="DynamicPages">