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
Conferences
Stylus Studio Feature Requests
(1192)
Stylus Studio Technical Forum
(14621)
Website Feedback
(249)
XSLT Help and Discussion
(7625)
sort by variable
(11)
[XSLT Recursive Template Help]...
(2)
Adding values with document() ...
(7)
merging xml files in to single...
(2)
merging xml files in to s...
Limit description characters i...
(2)
problem parsing xml as text in...
(2)
Summarize/Distinct
(5)
unix epoch seconds to date str...
(3)
xml, xslt question
(5)
LGCL XSLT transformation
(3)
Dynamic include
(3)
.rdbxml as XML within Stylus ...
(3)
Array of Values From XSL
(2)
Problem Saving output
(2)
Base 64 encoded data embedded ...
(2)
XML-XML Mapping
(2)
Parameterized 'Document()' ......
(1)
Newbie prob - Elements with sa...
(3)
.net 1.1 incorrectly processin...
(1)
xs:key and xs:keyref question
(5)
pass xsl-variable to javascrip...
(2)
Previous
[1321-1340]
[1341-1360]
[1361-1380]
Next
XQuery Help and Discussion
(2017)
Stylus Studio FAQs
(159)
Stylus Studio Code Samples & Utilities
(364)
Stylus Studio Announcements
(113)
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
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.