|
|
 |
| XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the XSLT section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |

August 1st, 2005, 02:02 AM
|
|
Authorized User
|
|
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
xml and xsl templates as input to xslt gives xml
Hi All,
Since i'm new to xslt i have some doubts in that.
My problem is to generate build.xml using xml and xml or xsl templates with the help of xslt.
For example i have one input.xml which contains input data to output xml and need to create a template either using xml or xsl.
Now i need to give both input.xml and templates as input to xslt
and generate the complete xml file that should be stored in the
specified directory.
i also do not know how to create template please help me in this regard.
the following are my xml files:
************************************************** *****
<project name="module-name" default="all" basedir=".">
<description>
Basic template that could be used as a build file by individual module owners.
</description>
<property name="module-name" value="from iput.xml some module name comes here"/>
<property name="module-dst" value="from input.xml fetch path value to the same module comes here"/>
<property name="rmic-class-name" value=" similarly here also some values here"/>
<property name="interface-class-name" value=" silmilarly here alsosome values here"/>
<target name="clean">
<delete>
<fileset dir="${module-dst}" />
</delete>
<echo message="Removed directory ${module-dst}"/>
</target>
<target name="compile" description="Compiling individual modules">
<rmic includes="${rmic-class-name}" base="${DST}" />
<jar destfile="${CLIENTJAR}" update="true">
<fileset dir=".">
<include name="*_Stub.class"/>
</fileset>
<fileset dir=".">
<include name="${interface-class-name}"/>
</fileset>
</jar>
</target>
<target name="all" depends="compile"/>
</project>
************************************************** ***********
in the above xml i need to modify some properties only and remaining
are same since it is ANT build file that has to be modified according to the specified module .i want to generate build.xml file
using xslt and put them in the particular place.
its very urgent for me please help me.
*************************************************
this is input.xml
<?xml version="2.0"?>
<subbuild>
<module>
<parameter module-name="communicator">
<parameter module-path="com\ram\nms\${module-name}">
<parameter rmic-classname="${module-path}\server\cache.class"> </module>
</subbuild>
***********************************
output.xml
build.xml with filled values.
Thanks and Regards
|

August 1st, 2005, 04:49 AM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
You say the problem is urgent: one thing I always advise people is that you shouldn't try to learn a new technology when you have deadlines. If the problem is urgent, tackle it using a technology you are already familiar with.
I'm a little confused by your requirement: I think you are using "template" with a general English meaning, not with its particular XSLT meaning, is that right? Similarly, your "path" is a filestore path, not an XPath path expression?
I think this transformation is basically an identity transformation:
<xsl:template match="*">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
supplemented by special code for the <property> element:
<xsl:template match="property">
<property>
<xsl:copy-of select="@name"/>
<xsl:attribute name="value">
<xsl:apply-templates select="@value"/>
</xsl:attribute>
</property>
</xsl:template>
<xsl:template match="property[@name='module-name']/@value">
<xsl:value-of select="document('input.xml')/subbuild/module/parameter/@module-name"/>
</xsl:template>
<xsl:template match="property[@name='module-dst']/@value">
<xsl:value-of select="document('input.xml')/subbuild/module/parameter/@module-path"/>
</xsl:template>
etc.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|

August 1st, 2005, 06:31 AM
|
|
Authorized User
|
|
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Michael Kay,
Thanks for your information.
But still i have some doubts like
How to create resultant xml using xml and xsl.
I want to store the resultant xml file in the specified directory how to do same.
I think you might have understood my requirement
I have a build.xml file in that i need to modify some property values according to the respective module and all remaining are same.
To avoid repeatation I need to create a template because that can be reused and create a seperate build.xml for each module.
please explain me in detail because i 'm new to this xslt.
but its very urgent.
i know how to do this using java but the requirement is in xslt.
Thanks and Regards
|

August 1st, 2005, 07:07 AM
|
 |
Wrox Author
Points: 12,735, Level: 48 |
|
|
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 3,923
Thanks: 0
Thanked 82 Times in 80 Posts
|
|
>How to create resultant xml using xml and xsl.
>I want to store the resultant xml file in the specified directory how to do same.
Every XSLT transformation takes an XML file as input, applies an XSLT stylesheet, and produces an XML (or sometimes HTML or text) file as output, so this question is pretty basic. The details of how to run it depend on the processor you are using. With Saxon, for example, running it from the command line, you would do:
java net.sf.saxon.Transform -o result.xml source.xml stylesheet.xsl
There's also a Java API allowing you to invoke transformations from your application.
I'm sorry, but telling me that it's urgent makes me feel it might have been a mistake to answer your question. You should either allow enough time in your schedule to learn this technology properly, or you should use a technology that you already understand.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
|

August 3rd, 2005, 02:55 AM
|
|
Authorized User
|
|
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Michael Kay,
Thanks for your information. Its working nicely but I need some more information like I need to add parameters for various modules in input.xml and then hoe to read all data from that file.
input.xml
<?xml version="2.0"?>
<subbuild>
<module name="comunicator">
<parameter module-name="communicator">
<parameter module-path="com\ram\nms\${module-name}">
<parameter rmic-classname="${module-path}\server\cache.class"> </module>
<module name="some module name comes here">
<parameter module-name="some values">
<parameter module-path="some values">
<parameter rmic-classname="some values">
</module
</subbuild>
|

August 3rd, 2005, 02:58 AM
|
|
Authorized User
|
|
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
it has to read one module at a time depends on the module name that we give
Thanks and Regards
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |