wood burning stoves*
The moose likes XML and Related Technologies and the fly likes How can I apply a XSL to the result of another XSL? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "How can I apply a XSL to the result of another XSL?" Watch "How can I apply a XSL to the result of another XSL?" New topic
Author

How can I apply a XSL to the result of another XSL?

Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
I�d like to apply a XSL to a XML generated from another XSL.
I cannot use VB or a different language to do this. I have no choice to use XSL.
XML => (XSL => XML => XSL)* => XML
* Done in one XSL
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12809
    
    5
That looks sort of like the chaining of XSLT transformer steps that takes place in Cocoon, but I don't think you need to get that complicated.
Mainly you need to realize that there are lots of ways to make a Source that a Transformer can read. Do you already have a particular XML toolkit that you have to use or can you use any Java? If you don't have anything already, download the latest XML pack from java.sun.com.
Bill
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
Yes, it�s like a sort of chaining of XSLT.
Unfortunately I cannot use Java.
I already have a client code which loads each XSL file and applys them to the XML (chaining). But I have to do the same process only using XSLT now.
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
parser input.xml ini.xsl output.xml
The ini.xsl file must call 4 xslt files in this order
1. filter.xsl (uses input.xml as a input xml file)
2. validator1.xsl (uses the xml file generated in step 1 as a input
xml file)
3. validator2.xsl (uses the xml file generated in step 1 as a input
xml file)
4. validator3.xsl (uses the xml file generated in step 1 as a input
xml file)
5. format.xsl (uses the xml file generated in step 2+3+4)
How to apply/call xsl file inside a xsl file?
How can I do that?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I'd just write a shell script to do these repeated invocations.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
Can I look at your shell script?
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
I don't quite understand the problem.
You are applying validator1.xsl, validator2.xsl, and validator3.xsl all to the same input file? You are not applying each step to the output of the previous step?
What do you mean by "uses the xml file generated in step 2+3+4" ?
Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
I have to apply validator1.xsl, validator2.xsl, and validator3.xsl to the result of the filter.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ms="urn:schemas-microsoft-com:xslt"
xmlns:user="userhtml">

<xsl:import href="filter.xsl"/>

<xsl:import href="validator1.xsl"/> //VALIDATE_Request1
<xsl:import href="validator2.xsl"/> //VALIDATE_Request2
<xsl:import href="validator3.xsl"/> //VALIDATE_Request3

<xsl utput omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/">
<xsl:call-template name="VALIDATE_Request1">
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>

I apply to the temporary result a template called VALIDATE_Request1. This works fine. But now, how can I apply the second template called VALIDATE_Request2 to the same temporary result?
You are not applying each step to the output of the previous step? No
What do you mean by "uses the xml file generated in step 2+3+4" ?
After applying each filter, I have to transform the result.
 
Don't get me started about those stupid light bulbs.
 
subject: How can I apply a XSL to the result of another XSL?