Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge 3 xml files using xslt

Status
Not open for further replies.

deep90

Programmer
Oct 4, 2004
1
US
Hi
I need to combine 3 xml files into one and do a search in that new file.I have to merge them using xsl.
My 3 files are







file 1: cat1.xml




<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="mer1.xsl"?>
<CATALOG>
<PRODUCT>
<TITLE>Kodak EasyShare DX7440 4-Megapixel Digital Camera</TITLE>
<COMPANY>Kodak</COMPANY>
<RESOLUTION>4 Megapixel</RESOLUTION>
<DESCRIPTION>Photos have incredible detail and sharpness with this advanced lens.The manual control dial gives you the freedom to create the photos you want with
control over the focus zone, image sharpness, aperture, shutter speeds and more.Choose from 16 scene modes to match the controls to the perfect settings. Modes include night, sports, landscape, close-up, children, snow, flower, fireworks
and beach.</DESCRIPTION>
<COST>299</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Kodak EasyShare DX6490 4-Megapixel Digital Camera</TITLE>
<COMPANY>Kodak</COMPANY>
<RESOLUTION>4 Megapixel</RESOLUTION>
<DESCRIPTION>View images, menus and settings through the high-resolution viewfinder.Choose a mode to match the controls to the perfect settings. Modes include
night, sports, landscape and close-up.Get true to-to-life color with this advanced technology.With the included software and optional docks, the Kodak EasyShare DX6490 fits
into the Kodak EasyShare system</DESCRIPTION>
<COST>399.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Nikon Coolpix® 5200 5.1-Megapixel Digital Camera</TITLE>
<COMPANY>Nikon</COMPANY>
<RESOLUTION>5.1 Megapixel</RESOLUTION>
<DESCRIPTION>The Nikon Coolpix® 5200 digital camera boasts a professional-quality Nikkor ED glass lens.Close in on the action with 3x optical and 4x digital zooms.
Watch the action and review images on the 1.5" LCD screen.Rapid power up and quick, precise autofocus.The macro mode focuses the camera as close as 1.6" away for amazing details.
</DESCRIPTION>
<COST>499.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Sony Cyber-shot® DSC-P52 3.2-Megapixel Digital Camera</TITLE>
<COMPANY>Sony</COMPANY>
<RESOLUTION>3.2 Megapixel</RESOLUTION>
<DESCRIPTION>This Sony digital camera delivers fabulous pictures with 3.2-megapixel resolution. Super HADT CCDs provide excellent image quality by allowing more light to pass to each pixel, increasing sensitivity and reducing noise.Close in on the action with the 2x optical zoom.
Watch the action and review images through the 1.6" LCD screen.The autofocus evaluates three separate areas of the frame to focus on the subject, not the background.
</DESCRIPTION>
<COST>199.99</COST>
</PRODUCT>
</CATALOG>



-----------------------------------------------------------

file 2: cat2.xml

<?xml version="1.0" encoding="utf-8" ?>
<CATALOG id="2">
<PRODUCT>
<TITLE>Panasonic 3CCD 3-Megapixel MiniDV Camcorder</TITLE>
<COMPANY>Panasonic</COMPANY>
<RESOLUTION>3 Megapixel</RESOLUTION>
<DESCRIPTION>Record high-quality digital video on small tapes.Three imaging devices pick up true-to-life color with separate 800K pixel CCDs for the reds, greens and blues that compose an image. The result is great detail with up to 540 lines of resolution.
Shoot 3-megapixel digital images on SD™ memory that are perfect for email or printing.The professional lenss delivers remarkably crisp images with true-to-life color and a high level of detail.The enormous 3.5" LCD delivers a clear picture of the action during recording and playback.
</DESCRIPTION>
<COST>1199.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Samsung MiniDV Camcorder</TITLE>
<COMPANY>Samsung</COMPANY>
<RESOLUTION>4 Megapixel</RESOLUTION>
<DESCRIPTION>2.5" LCD delivers a clear picture of the action during recording and playback.The 20x optical and 400x digital zooms bring the action to you from any distance.
The advanced image stabilization system keeps shots steady, even when using the zoom or LCD screen.Print digital stills directly from your camcorder, without a PC, using any PictBridge-enabled printer.
Records high-quality digital video on small tapes
</DESCRIPTION>
<COST>1399.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>SONY MiniDV Camcorder</TITLE>
<COMPANY>SONY</COMPANY>
<RESOLUTION>5 Megapixel</RESOLUTION>
<DESCRIPTION>Record high-quality digital video on small tapes.Catch snapshots perfect for email.This 680K pixel imaging device picks up stunning details.The oversized, 3.5" LCD delivers a clear picture of the action during recording and playback.
Just press the Easy-Q button to reset controls to the basic settings for easy shooting.The 20x optical and 900x digital zooms bring the action to you from any distance.The digital image stabilization system makes video smooth and steady.</DESCRIPTION>
<COST>1299.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Canon ZR85 MiniDV Camcorder</TITLE>
<COMPANY>Canon</COMPANY>
<RESOLUTION>4 Megapixel</RESOLUTION>
<DESCRIPTION>Record high-quality digital video on small tapes.Catch snapshots perfect for email.This 680K pixel imaging device picks up stunning details.
The Easy Navigator and Op system make it easy to set the controls and shoot footage. Or, just press the Easy-Q button to reset back to the basic settings.
The 18x optical and 900x digital zooms bring the action to you from any distance.The digital image stabilization system makes video smooth and steady.

</DESCRIPTION>
<COST>1399.99</COST>
</PRODUCT>
</CATALOG>

___________________________________________________________




file 3: cat3.xml

<?xml version="1.0" encoding="utf-8" ?>
<CATALOG3>
<PRODUCT>
<TITLE>Nikon Coolpix® 5200 5.1-Megapixel Digital Camera</TITLE>
<COMPANY>Nikon</COMPANY>
<RESOLUTION>5.1 Megapixel</RESOLUTION>
<DESCRIPTION>The Nikon Coolpix® 5200 digital camera boasts a professional-quality Nikkor ED glass lens.Close in on the action with 3x optical and 4x digital zooms.
Watch the action and review images on the 1.5" LCD screen.Rapid power up and quick, precise autofocus.The macro mode focuses the camera as close as 1.6" away for amazing details.
</DESCRIPTION>
<COST>499.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Sony Cyber-shot® DSC-W1 5.1-Megapixel Digital Camera</TITLE>
<COMPANY>Sony</COMPANY>
<RESOLUTION>5.1 Megapixel</RESOLUTION>
<DESCRIPTION>This Sony Cyber-shot® digital camera delivers stunning pictures with 5.1-megapixel resolution. Super HAD™ CCDs provide excellent image quality by allowing more light to pass to each pixel, increasing sensitivity and reducing noise.Close in on the action with 3x optical zoom and 2x digital zoom.
Watch the action and review images through the enormous 2.5" LCD screen.The advanced lens uses an optical multi-layer coating to deliver vivid images and true-to-life color saturation, even with subtle tones.Sony's Real Imaging Processor provides outstanding image quality, faster speed and improved battery life.
</DESCRIPTION>
<COST>399.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Kodak EasyShare CX7300 3.2-Megapixel Digital Camera</TITLE>
<COMPANY>Kodak</COMPANY>
<RESOLUTION>3.2 Megapixel</RESOLUTION>
<DESCRIPTION>The Kodak EasyShare CX7300 digital camera delivers pictures with 3.2-megapixel resolution.Check out details with the 3x digital zoom.
Watch the action and review images through the 1.6" LCD screen.Capture up to 30 seconds of QuickTime video.Tag favorite pictures to print or email as soon as you take them.
</DESCRIPTION>
<COST>299.99</COST>
</PRODUCT>
<PRODUCT>
<TITLE>Canon ZR85 MiniDV Camcorder</TITLE>
<COMPANY>Canon</COMPANY>
<RESOLUTION>4 Megapixel</RESOLUTION>
<DESCRIPTION>Record high-quality digital video on small tapes.Catch snapshots perfect for email.This 680K pixel imaging device picks up stunning details.
The Easy Navigator and Op system make it easy to set the controls and shoot footage. Or, just press the Easy-Q button to reset back to the basic settings.
The 18x optical and 900x digital zooms bring the action to you from any distance.The digital image stabilization system makes video smooth and steady.

</DESCRIPTION>
<COST>1399.99</COST>
</PRODUCT>
</CATALOG3>


__________________________________________________________

I want to store it as a new file called cat4.xml.
Could someone please give me an xsl file to combine these 3 together.I tried ...but i could not figure where the resulting file was getting stored.
Any help is greatly appreciated.Thanks!

Deepa
 
Maybe I dont understand what you want to achieve, but I wonder: why do you want to use XSL?
You will have to execute the transformation, and pass parameters for file-locations, programmaticaly anyway.
So: why not just write a function that loads xml in (for example) domdocuments, and adds nodes from one document to another?
A simple search using XPath is also easy to implement.
 
If it weren't for those pesky
Code:
<?xml version="1.0" encoding="utf-8" ?>
declarations, cat would do the job.
 
The xml-declaration should not be a problem for any xml-parser to load a file.
Check out the documentation for the parser you're using, and find out how to load files, select and copy nodes.
Good luck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top