[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: create new xml with xsl

Subject: RE: create new xml with xsl
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Fri, 7 Feb 2003 13:56:14 -0000
re create liberty
You are trying to create a pipeline of two transformations. You can
either do this with one stylesheet, or with two. 

If you do it with two, you will need some kind of scripting environment
(e.g. a Java or VB application, or just a shell script) to feed the
result of the first transformation as input to the second.

If you want to do it with a single stylesheet, the design pattern is:


<xsl:variable name="temp">
  <xsl:apply-templates select="/" mode="phase1"/>
</xsl:variable>

<xsl:template match="/">
  <xsl:apply-templates select="xx:node-set($temp)" mode="phase2"/>
</xsl:template>

and then you have to label all the template rules for each
transformation phase as mode="phase1" or mode="phase2". xx:node-set() is
your vendor's extension function to convert a temporary tree to a
node-set - all processors offer this, but the name varies.

Saxon offers a third approach, you can use two stylesheets, and pipe the
output of the first into the second using <xsl:output
saxon:next-in-chain="stylesheet2.xsl"/>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of jandra x
> Sent: 07 February 2003 12:12
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  create new xml with xsl
> 
> 
> Hi everybody! I have this project for my school and i cant 
> seem to find any 
> good solution. I searched the list but nothing seems to help me 
> exactly...What i want to do is to create a new xml document 
> from an original 
> one using a simple xsl and then reuse this xml to ctreate another xml 
> document with another xsl. Everything should be the simplest 
> possible. I 
> cant seem to work the combination of these xsl's.
> 
> My original xml document includes clients from different 
> countries.At first 
> i want to create anew xml doc which will have onlyclients 
> from USA and then 
> a new xml doc which will have only those from ny. Assume that 
> USA=1 and 
> ny=11(all the other countries have different numbers..)
> 
> For example this is a part from my original xml:
> 
> <client>
>   <fname>george</name>
>   <lastname>qwerty</lastname>
>   <address>1</address>
>   <region>12</region>
>   <email>hotmail</email>
>   <phone>200897456</phone>
> </client>
> 
> <client>
>   <fname>george</name>
>   <lastname>liberty</lastname>
>   <address>1</address>
>   <region>14</region>
>   <email>hotmail</email>
>   <phone>20084457456</phone>
> </client>
> 
> <client>
>   <fname>nick</name>
>   <lastname>klipd</lastname>
>   <address>1</address>
>   <region>19</region>
>   <email>hotmail</email>
>   <phone>200855</phone>
> </client>
> 
> <client>
>   <fname>alex</name>
>   <lastname>poly</lastname>
>   <address>1</address>
>   <region>11</region>
>   <email>hotmail</email>
>   <phone>20013131</phone>
> </client>
> 
> <client>
>   <fname>owen</name>
>   <lastname>nitro</lastname>
>   <address>7</address>
>   <region>71</region>
>   <email>yahoo</email>
>   <phone>8003698</phone>
> </client>
> 
> <client>
>   <fname>what</name>
>   <lastname>who</lastname>
>   <address>7</address>
>   <region>78</region>
>   <email>yahoo</email>
>   <phone>98</phone>
> </client>
> 
> <client>
>   <fname>owen</name>
>   <lastname>bishop</lastname>
>   <address>7</address>
>   <region>76</region>
>   <email>yahoo</email>
>   <phone>800</phone>
> </client>
> etc....
> 
> So with my first xsl i wnat to create this sort of xml
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="8.xsl"?>
> <wow>
> <client>
>   <fname>george</name>
>   <lastname>qwerty</lastname>
>   <address>1</address>
>   <region>12</region>
>   <email>hotmail</email>
>   <phone>200897456</phone>
> </client>
> 
> <client>
>   <fname>george</name>
>   <lastname>liberty</lastname>
>   <address>1</address>
>   <region>14</region>
>   <email>hotmail</email>
>   <phone>20084457456</phone>
> </client>
> 
> <client>
>   <fname>nick</name>
>   <lastname>klipd</lastname>
>   <address>1</address>
>   <region>19</region>
>   <email>hotmail</email>
>   <phone>200855</phone>
> </client>
> 
> <client>
>   <fname>alex</name>
>   <lastname>poly</lastname>
>   <address>1</address>
>   <region>11</region>
>   <email>hotmail</email>
>   <phone>20013131</phone>
> </client>
> </wow>
> 
> and then with the second xsl this xml:
> 
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <?xml-stylesheet type="text/xsl" href="8.xsl"?>
> <wow>
> <client>
>   <fname>alex</name>
>   <lastname>poly</lastname>
>   <address>1</address>
>   <region>11</region>
>   <email>hotmail</email>
>   <phone>20013131</phone>
> </client>
> </wow>
> ....
> 
> what i cant achieve is to cobine the two xsl files.import or 
> include dont 
> seem to work. i use if to take only the clients from usa and 
> then copy-of 
> select to create the new tree with them and then in the 
> different xsl the 
> same idea to take the nyorkers.
> The code is something like this:
> 
> <xsl:stylesheet 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
> version="1.0"> <xsl:output method="xml" indent="yes"/> 
> <xsl:template match="/"> <xsl:apply-templates/> 
> </xsl:template> <xsl:template match="clients"> <xsl:if 
> test="address='1'"> <xsl:element name="client">
>      <xsl:element name="fname"><xsl:copy-of 
> select="./fname"/></xsl:element>
>      <xsl:element name="lastname"><xsl:copy-of 
> select="./lastname"/></xsl:element>
>      <xsl:element name="address"><xsl:copy-of 
> select="./address"/></xsl:element>
>      <xsl:element name="region"><xsl:copy-of 
> select="./region"/></xsl:element>
>      <xsl:element name="email"><xsl:copy-of 
> select="./email"/></xsl:element>
>      <xsl:element name="phone"><xsl:copy-of 
> select="./phone"/></xsl:element> </xsl:element> </xsl:if> 
> </xsl:template> </xsl:stylesheet>
> 
> (**if this is my correct file..:)
> But i cant combined them into one.What should i do with the 
> xml file so that 
> it will see first the first xsl and then the second???? This 
> is exactly what 
> my professor wants. He wants us to create 2 diferrent xsl's 
> and to apply 
> them somehow to the xml file and the output of the first to 
> go as input to 
> the second ant thus create the last xml file.
> I'm stuck.Do i have to use java as i've seen in some other 
> messages in the 
> list??
> PLEASEEEEEEE anyone outthere?
> Thank u in advance and sorry for the huge msg..
> 
> _________________________________________________________________
> STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
> http://join.msn.com/?page=features/junkmail
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.