oxygen diff documentation/capabilities
Oxygen general issues.
-
- Posts: 2
- Joined: Wed Jan 11, 2012 6:34 pm
oxygen diff documentation/capabilities
Hello
I am evaluating Oxygen diff ( and the suite as a whole) for possible inclusion in our standard enterprise install.
One of the tasks we need to have the users be able to do is merge two ( or more ) xml files into one combined xml file.
so two files with the following
file1.xml
<root>
<element value="a">
</element>
</root>
file2.xml
<root>
<element value="b">
</element>
</root>
would be combined into
<root>
<element value="a">
</element>
<element value="b">
</element>
</root>
This assumes that the DTDs match and the elements are unique of course. The documentation and demo for diff both MENTION merge but provide no examples or information if the simple task above is possible.
Does anyone know if the tasks above is possible with any of the tools in the oxygen suite ?
thanks
I am evaluating Oxygen diff ( and the suite as a whole) for possible inclusion in our standard enterprise install.
One of the tasks we need to have the users be able to do is merge two ( or more ) xml files into one combined xml file.
so two files with the following
file1.xml
<root>
<element value="a">
</element>
</root>
file2.xml
<root>
<element value="b">
</element>
</root>
would be combined into
<root>
<element value="a">
</element>
<element value="b">
</element>
</root>
This assumes that the DTDs match and the elements are unique of course. The documentation and demo for diff both MENTION merge but provide no examples or information if the simple task above is possible.
Does anyone know if the tasks above is possible with any of the tools in the oxygen suite ?
thanks
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: oxygen diff documentation/capabilities
Hello,
Unfortunately the XML Diff tool does not provide an automatic way of performing this kind of merge/append operation. When comparing the two files the tool will see the differences and propose to copy the changes(overwrite) to one side or the other. There's also an append operation but it's not XML aware(e.g. it only copies the start tag). So you would have to manually select and copy the entire element from one side and paste it on the other.
You would need to write and apply an XML stylesheet in Oxygen to automate this type of merge operation.
Let me know if you are interested in such a stylesheet or you are just inquiring about the application capabilities.
Regards,
Adrian
Unfortunately the XML Diff tool does not provide an automatic way of performing this kind of merge/append operation. When comparing the two files the tool will see the differences and propose to copy the changes(overwrite) to one side or the other. There's also an append operation but it's not XML aware(e.g. it only copies the start tag). So you would have to manually select and copy the entire element from one side and paste it on the other.
You would need to write and apply an XML stylesheet in Oxygen to automate this type of merge operation.
Let me know if you are interested in such a stylesheet or you are just inquiring about the application capabilities.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 2
- Joined: Wed Jan 11, 2012 6:34 pm
Re: oxygen diff documentation/capabilities
Adiran
thanks for your response.
I am interested in seeing an generic xslt style sheet that would preform a merge on two or more XML files.
However I am curious. If XML Diff & merge does not actually merge XML then what is the merge referring to ?
thanks for your response.
I am interested in seeing an generic xslt style sheet that would preform a merge on two or more XML files.
However I am curious. If XML Diff & merge does not actually merge XML then what is the merge referring to ?
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: oxygen diff documentation/capabilities
It's called Diff and Merge because it has the ability to compare and show the differences between two files(that's the diff) and also allows the user to easily copy/append/replace the differences selectively from one file to the other afterwards(that's the merge). I guess we should call it manual merge, but that is the only type of merge available for a two way diff.
The thing is you cannot automatically merge two files with a two way diff(2 files), there is no way to determine if something was added or just changed from the two files. To merge two XML files you would need a merge criterion(or several criteria).
A three way diff on the other hand, like version control systems have(e.g. SVN), can actually merge files automatically because there is a third file, a common ancestor of the two, and the diff can compare each file with that ancestor and determine what has been changed and what has been added/removed from each of the files that have to be merged.
Here's a simple XML stylesheet that merges two XML files in the output. This actually copies all the children elements from the root of one document and appends them at the end of the other.
To run this in Oxygen, you have to create and associate a transformation scenario. Open the main XML file that you want the changes to be merged to(the one that has translations for several languages if any).
From the main menu invoke Document -> Transformation -> Configure Transformation Scenario(there's a corresponding action in the toolbar)
Further on, make sure the scenario type is "XML transformation with XSLT" and click 'New' to create a new scenario:
1. Give it an appropriate name
2. Leave the 'XML URL' field to its default(${currentFileURL})
3. In the XSL URL field browse for the stylesheet.
4. Press the "Parameters" button and set the two parameters there.
5. You can further tune the 'Output'. e.g in the 'Save as' field you can specify: ${cfd}/${cfn}-out.xml which translates into <current-file-directory>/<current-filename>-out.xml
The "Save as" field must refer a single file, NOT an output directory.
6. OK in all dialogs.
To apply this transformation use : Document -> Transformation -> Apply Transformation Scenario(there's a corresponding action in the toolbar).
Let me know if you need further assistance with this.
Regards,
Adrian
The thing is you cannot automatically merge two files with a two way diff(2 files), there is no way to determine if something was added or just changed from the two files. To merge two XML files you would need a merge criterion(or several criteria).
A three way diff on the other hand, like version control systems have(e.g. SVN), can actually merge files automatically because there is a third file, a common ancestor of the two, and the diff can compare each file with that ancestor and determine what has been changed and what has been added/removed from each of the files that have to be merged.
Here's a simple XML stylesheet that merges two XML files in the output. This actually copies all the children elements from the root of one document and appends them at the end of the other.
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:param name="mergedFilePath" select="'mergedFile.xml'"/>
<!-- Match document -->
<xsl:template match="/">
<xsl:text>
</xsl:text>
<xsl:copy>
<xsl:apply-templates mode="copyRoot"/>
</xsl:copy>
</xsl:template>
<!-- Deep copy root of main file, append second file -->
<xsl:template match="*|text()|@*" mode="copyRoot">
<xsl:copy>
<xsl:apply-templates mode="copy" select="@*"/>
<xsl:apply-templates mode="copy"/>
<xsl:variable name="mergedDoc" select="document($mergedFilePath)"/>
<xsl:apply-templates mode="copy" select="$mergedDoc/*/*|$mergedDoc/*/text()"/>
</xsl:copy>
</xsl:template>
<!-- Deep copy template -->
<xsl:template match="*|text()|@*" mode="copy">
<xsl:copy>
<xsl:apply-templates mode="copy" select="@*"/>
<xsl:apply-templates mode="copy"/>
</xsl:copy>
</xsl:template>
<!-- Handle default matching -->
<xsl:template match="*"/>
</xsl:stylesheet>
From the main menu invoke Document -> Transformation -> Configure Transformation Scenario(there's a corresponding action in the toolbar)
Further on, make sure the scenario type is "XML transformation with XSLT" and click 'New' to create a new scenario:
1. Give it an appropriate name
2. Leave the 'XML URL' field to its default(${currentFileURL})
3. In the XSL URL field browse for the stylesheet.
4. Press the "Parameters" button and set the two parameters there.
5. You can further tune the 'Output'. e.g in the 'Save as' field you can specify: ${cfd}/${cfn}-out.xml which translates into <current-file-directory>/<current-filename>-out.xml
The "Save as" field must refer a single file, NOT an output directory.
6. OK in all dialogs.
To apply this transformation use : Document -> Transformation -> Apply Transformation Scenario(there's a corresponding action in the toolbar).
Let me know if you need further assistance with this.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service