xsl-list
[Top] [All Lists]

[xsl] Access XML from the URL and put in different file

2011-04-13 12:15:56

Hello All,
Following is the test xml I am working on
<Description>   <core 
resource="http://xyz.com/93034B4E-5686-4FF5-9EAD-F603F42B897F/viewas/xml"/>     
  <core 
resource="http://xyz.com/E4E0EF48-030F-4ACE-B15E-E923AC582A6B/viewas/xml"/>     
  <core 
resource="http://xyz.com/9808A0E2-5678-435F-8C89-5B7C8C27E380/viewas/xml"/>     
  <core 
resource="http://xyz.com/80E137ED-E8CC-4B14-AC47-E437D8E91BBA/viewas/xml"/>     
  <core 
resource="http://xyz.com/97337AAC-81CF-4DD8-9C8F-B06744B13753/viewas/xml"/>     
  <core 
resource="http://xyz.com/114F7C46-C207-49BE-96D1-B5E4314342B9/viewas/xml"/><Description>
The value of resource attribute is a link to the XML document. I need to write 
an XSLT which creates 6 different output file (as there are 6 <core>), and 
every output file should have their respective XML.
=========This is the test.xslt I wrote<xsl:stylesheet version="2.0" 
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; 
xmlns:fn="http://www.w3.org/2005/xpath-functions";>     <xsl:output method="xml" 
version="1.0" encoding="UTF-8" indent="yes" name="xml"/>       <xsl:template 
match="/">                <xsl:for-each select="//core">                  
<xsl:variable name="filename" 
select="concat('output1/',substring(substring-after(@*:resource,'xyz.com/'),1,5),'.xml')"/>
                       <xsl:value-of select="$filename"/>                      
<!-- Creating  -->                      <xsl:result-document href="{$filename}" 
format="xml">                           <xsl:value-of select="@*:resource"/>    
                </xsl:result-document>          </xsl:for-each> 
</xsl:template></xsl:stylesheet>===========I was able to get 6 different xml 
files, but they were having the value of the respective resource attribute, not 
the whole XML.

Output========<?xml version="1.0" 
encoding="UTF-8"?>http://xyz.com/93034B4E-5686-4FF5-9EAD-F603F42B897F/viewas/xml
Required output is to get the whole XML, which appears when the link is 
clicked/navigated.
Is there any way I can achieve this using XSLT.
Thanks,Shashank Jain                                      
--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>