Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 1st, 2005, 01:02 AM
Authorized User
 
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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


Reply With Quote
  #2 (permalink)  
Old August 1st, 2005, 03:49 AM
mhkay's Avatar
Wrox Author
Points: 17,570, Level: 57
Points: 17,570, Level: 57 Points: 17,570, Level: 57 Points: 17,570, Level: 57
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,800
Thanks: 0
Thanked 260 Times in 255 Posts
Default

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
Reply With Quote
  #3 (permalink)  
Old August 1st, 2005, 05:31 AM
Authorized User
 
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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



Reply With Quote
  #4 (permalink)  
Old August 1st, 2005, 06:07 AM
mhkay's Avatar
Wrox Author
Points: 17,570, Level: 57
Points: 17,570, Level: 57 Points: 17,570, Level: 57 Points: 17,570, Level: 57
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,800
Thanks: 0
Thanked 260 Times in 255 Posts
Default

>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
Reply With Quote
  #5 (permalink)  
Old August 3rd, 2005, 01:55 AM
Authorized User
 
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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>


Reply With Quote
  #6 (permalink)  
Old August 3rd, 2005, 01:58 AM
Authorized User
 
Join Date: Jul 2005
Location: bangalore, karnataka, India.
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default

it has to read one module at a time depends on the module name that we give


Thanks and Regards

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple input xml / get data from other xml file elayaraja.s XSLT 3 July 25th, 2008 06:59 AM
Converting Source Xml into Target Xml Using XSL. alapati.sasi XSLT 3 May 14th, 2007 10:54 AM
XSLT transformation from XML buffer and XSL file sundaramkumar Javascript 1 September 5th, 2005 02:11 AM
xsl:apply-templates on Variable containing xml nexus5 XSLT 9 November 4th, 2004 01:55 PM
merge two xml file and make new xml using xslt ketan XSLT 0 September 21st, 2004 08:48 AM



All times are GMT -4. The time now is 02:57 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.