Re: [xsl] Combining two files

Subject: Re: [xsl] Combining two files
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sun, 12 Dec 2010 00:42:43 +0000
On 12/12/2010 00:31, Mark wrote:
I actually wrote this several years ago when I was just learning XSLT. Since it worked, I moved on to tougher problems. I am embarrassed to ask, but what is it I donbt understand? I could not get these two files combined without doubling one of them until I used bdummy.xmlb (an empty xml file) in the bat file command line:

You haven't said what else you tried, so it's hard to tell you why it didn't work. Not sure what you mean by "without doubling one of them". If you don't want a dummy input file you can always change match="/*" on this template to name="main", and set -it:main on the command line. And delete the "* |" from the select, which doesn't seem to be doing anything useful.


Michael Kay
Saxonica


java -jar c:\Users\HP\saxon\saxon9.jar dummy.xml xslt\40Combine.xsl > work\40Combined.xml


My style sheet 40Combine.xsl consists of a single template:

<xsl:template match="/*">
<xsl:copy>
<xsl:copy-of select="* | document('../work/22Authors.xml')/*/*" copy-namespaces="no"/>
<xsl:copy-of select="* | document('../work/35Subjects.xml')/*/*" copy-namespaces="no"/>
</xsl:copy>
</xsl:template>




22Authors.xml contains:
<List>
<Item>
<Heading entry="author"> Tabor, South Dakota. Chamber of Commerce </Heading>
<Article>
<Title>Czech days stamp cancellation</Title>
<IssueName>May/Jun</IssueName>
<Year>2007</Year>
<Page>22</Page>
<IssueNumber>3</IssueNumber>
</Article>
<Article>
<Title>Czech days stamp cancellation</Title>
<IssueName>May/Jun</IssueName>
<Year>2008</Year>
<Page>2</Page>
<IssueNumber>3</IssueNumber>
<Comment>
<Article>
<Person>Dennis Povondra</Person>
<Title>Philatelic news and views</Title>
<IssueName>May/Jun</IssueName>
<IssueNumber>3</IssueNumber>
<Year>2008</Year>
<Page>27</Page>
</Article>
</Comment>
</Article>
</Item>
<!bmany more items b>
</List


35Subjects.xml contains a similar set of items:
<List>
<Item>
<Heading id="A1" entry="subject"> TC!bor, Bohemia</Heading>
<Level1>
<SubDiv1 id="A1-2" catalog="1" scott-number="716" pofis-number="849">1955</SubDiv1>
<Article>
<Person>Bulletin of the Ministry of Posts</Person>
<Title>New issues [Title varies or absent]</Title>
<IssueName>Nov</IssueName>
<IssueNumber>9</IssueNumber>
<Year>1955</Year>
<Page>134</Page>
</Article>
</Level1>
</Item>
<!bmany more items b>
</List>


Thanks,
Mark

Current Thread