Sign Up
Search
Options
search
Chat
Help
News
Log in
Not Logged in
Home
»
Boards
»
Stylus Studio Developer Network
»
XSLT Help and Discussion
»
merging xml files in to single xml file
Topic
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
next
Subject:
merging xml files in to single xml file
Author:
vijay reddy
Date:
07 Oct 2006 06:27 AM
hi
I have to merge 2 xml files in to single xml file
so i found a xslt for this requierment .
so i donot no how to get the output for this problem.
any help will be appriciated.
my xml files
input1.xml
<?xml version="1.0"?>
<PreVCD>
<component name="stack">
<subpath path="stack_environment">
<variable var="ins" symbol="!" wireonbus="1"/>
</subpath>
</component>
<dump>
<time t="0">
<data>
<symbol sign="!" value="0"/>
</data>
</time>
<time t="10">
<data>
<symbol sign="!" value="1"/>
</data>
</time>
<time t="25">
<data>
<symbol sign="!" value="0"/>
</data>
</time>
</dump>
</PreVCD>
input2.xml
-----------
<?xml version="1.0"?>
<PreVCD>
<component name="stack">
<subpath path="stack_behavior">
<variable var="i" symbol="@" bussize="1"/>
</subpath>
</component>
<dump>
<time t="0">
<data>
<symbol sign="@" value="0"/>
</data>
</time>
<time t="5">
<data>
<symbol sign="@" value="1"/>
</data>
</time>
<time t="10">
<data>
<symbol sign="@" value="0"/>
</data>
</time>
<time t="20">
<data>
<symbol sign="@" value="1"/>
</data>
</time>
</dump>
</PreVCD>
The ouput should look like:
<PreVCD>
<component name="stack">
<subpath path="stack_behavior">
<variable var="i" symbol="@" bussize="1"/>
</subpath>
<subpath path="stack_environment">
<variable var="ins" symbol="!" wireonbus="1"/>
</subpath>
</component>
<dump>
<time t="0">
<data>
<symbol sign="@" value="0"/>
<symbol sign="!" value="0"/>
</data>
</time>
<time t="5">
<data>
<symbol sign="@" value="1"/>
</data>
</time>
<time t="10">
<data>
<symbol sign="@" value="0"/>
<symbol sign="!" value="1"/>
</data>
</time>
<time t="20">
<data>
<symbol sign="@" value="1"/>
</data>
</time>
<time t="25">
<data>
<symbol sign="!" value="0"/>
</data>
</time>
</dump>
</PreVCD>
the xslt file
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="
http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="no" encoding="UTF-8"/>
<xsl:variable name="doc2" select="document('input2.xml')" />
<xsl:template match="/">
<xsl:apply-templates select="PreVCD"/>
</xsl:template>
<xsl:template match="PreVCD">
<xsl:copy>
<xsl:apply-templates select="component" />
<xsl:apply-templates select="dump" />
</xsl:copy>
</xsl:template>
<xsl:template match="component">
<xsl:copy>
<xsl:copy-of select="subpath | $doc2/PreVCD/component/subpath"
/>
</xsl:copy>
</xsl:template>
<xsl:template match="dump">
<xsl:copy>
<xsl:apply-templates select="time |
$doc2/PreVCD/dump/time[not(@t = current()/time/@t)]" >
<xsl:sort select="@t" data-type="number"
order="ascending" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="time">
<xsl:copy>
<xsl:copy-of select="@*" />
<xsl:apply-templates select="data" />
</xsl:copy>
</xsl:template>
<xsl:template match="data">
<xsl:variable name="curTime" select="../@t" />
<xsl:copy>
<xsl:copy-of select="* | $doc2/PreVCD/dump/time[@t =
$curTime]/data/*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
how to see the output.i mean how these progam will be run
how to get the output xml file.
top
Subject:
merging xml files in to single xml file
Author:
Ivan Pedruzzi
Date:
10 Oct 2006 10:16 AM
Open your stylesheet in Stylus Studio set XML input URL to the desired document click the green triangle.
Hope this helps
Ivan Pedruzzi
Stylus Studio Team
http://www.stylusstudio.com/xml_download.html
Topic Page
1
2
3
4
5
6
7
8
9
Prev Topic
Next Topic
Powered by
Stylus Studio
, the world's leading
XML IDE
for
XML
,
XSLT
,
XQuery
,
XML Schema
,
DTD
,
XPath
,
WSDL
,
XHTML
,
SQL/XML
, and
XML Mapping
!
Go to Conference:
Select Conference
Stylus Studio Feature Requests
Stylus Studio Technical Forum
Website Feedback
XSLT Help and Discussion
XQuery Help and Discussion
Stylus Studio FAQs
Stylus Studio Code Samples & Utilities
Stylus Studio Announcements
go
Log In Options
Username:
Password:
Site Map
|
Privacy Policy
|
Terms of Use
|
Trademarks
Stylus Scoop XML Newsletter:
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.