XSL: of a list of xml files, create single DITA files based on the xml element contents

Questions about XML that are not covered by the other forums should go here.
oxygen-user
Posts: 10
Joined: Wed Jan 24, 2024 4:36 pm

XSL: of a list of xml files, create single DITA files based on the xml element contents

Post by oxygen-user »

Hi,
Suppose I have several XML files of the following structure (below).

For each group element, create a DITA file <group-name>.dita that contains all the group elements. (There should be some more configuration/mapping behind it but that's manageable for me.)
If there are same-name groups in an XML file or across XML files, also list those groups.

I tried this in various ways with XSL, etc. but there are always conflicts between same-name groups.
  • When I try to merge and split this with one XSL file, then only one same-name group/all same-name groups of one file but not of other files get generated to the output.
  • So I tried merging all XML contents to one file as described in general-xml-questions/topic11375.html. Then I used another xsl stylesheet to generate the output. However, this resulted in a Saxon error:
    Cannot write more than one result document to the same URI.
    (In theory it works better than the first option, so the xsl stylesheet also considers other files with same-name groups. However, if one same-name group is directly followed by another one, then the error occurs.

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="no"?><configuration>

	
	
	
	<group name="gruppnoans" >
		<parameter name = "testingoans"	value = "true" type="BOOLEAN">
			<description lang="en">English text.. he.</description>
			<description lang="de">... he</description>
		</parameter>
	</group>

	
	
	<group name="gruppnzowa" >
	
		<parameter name="elementoans"		value="false"			type="BOOLEAN">
			<description lang="en">English text a</description>
			<description lang="de">bla bla  a</description>
		</parameter>
		
		<parameter name="element.zwoa"			value="C:\tiger"			type="STRING">
			<description lang="en">English text...</description>
			<description lang="de">bla bla...</description>
		</parameter>
		
		<parameter name="ajkdjfaklsdj"	value="1,MINUTE"		type="PERIOD">
			<description lang="en">English text</description>
			<description lang="de">de</description>
		</parameter>
		
	</group>
	

</configuration>
xephon
Posts: 159
Joined: Mon Nov 24, 2014 1:49 pm
Location: Greven/Germany

Re: XSL: of a list of xml files, create single DITA files based on the xml element contents

Post by xephon »

This can be done with pure XSLT. But this might take a few hours. You should have a look at the uri-collection() function and the <xsl:result-doxument> instruction. You should be able to develop a solution with these.
stefan-jung.org – Your DITA/DITA-OT XML consultant
Post Reply