This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes xsl templates Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "xsl templates" Watch "xsl templates" New topic
Author

xsl templates

shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Hello,
Can I import code from other xml files using XSLT. For example I have two files A.xml,B.xml. Now I would like to modify(include) A.xml with code that is present in B.xml. How can I achieve it using an xsl??
If I define templates, then I would have to copy the code present in B.xml into my template. But I dont wanna do this. Is there any way so that I can just modify one file with another using an XSL without duplicating code.
shankar,
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
Please read the archives from this URL, it will sure suit ur need.
Rgds
Balaji


Spritle Software Blogs
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
I just learned this recently, and made an example available on the web. If you need to do complicated manipulation on the multi-document, you might need to use vender specific extention. This example might of some help.
http://bobcat.webappcabaret.net/javachina/faq/xslt_01.htm#xslt_ex_Q01
See the result and source first if you like:
http://bobcat.webappcabaret.net/javachina/faq/xslt_ex_Q01_result.htm
http://bobcat.webappcabaret.net/javachina/faq/xslt_ex_Q01_source.htm
shankar vembu
Ranch Hand

Joined: May 10, 2001
Posts: 309
Balaji and Roseanne,
Thanx for the replies. I went thru the links you mentioned.But i am not sure whether they would solve my problem.I need to just include an xml file(alongwith tags) in another xml file thereby producing a (bigger) output xml.Example:
source file
<root>
<include>
<file>inc.xml</file>
</include>
</root>
inc.xml
<firm>
<employee>
<name>XYZ</name>
<age>21</age>
</employee>
</firm>
output file
<root>
<name>XYZ</name>
<age>21</age>
</root>
So,I want to pick some tags from an xml file and add(include) them in another.But in the examples mentioned in the urls, the content of xml files are being merged to produce an html output.Am I missing something here???
Shankar.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
The first part of my xslt code is more than sufficient to solve your problem. You don't even need the extention. However, you do need to write a few lines of code, copying will not work.
Balaji's link is very specific to your question, however, you still need to read them, and digest. Then you need to apply what you learned from there, and write a few lines of your own code.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: xsl templates
 
Similar Threads
Modify string
how to open xml file into html page
retrive attribute value from another xml file
tool for writing XSLT/XQuery
Producer/Consumer Question