Subject: Re: Combining two files
From: "Mark" <mark@xxxxxxxxxxxx>
Date: Sat, 11 Dec 2010 18:44:14 -0800
|
Hi Michael,
I forgot to mention the result I want: a new xml document with the <Items>
(and their children) from both files in a single list as children of a new
<List> element --that is, make a single <List> of both files in a new
document. Since I made my original tries a few years ago, I no longer know
what I did wrong then. Although my style sheet works, I am confident I do
not understand the proper way to do this.
Sorry to be so dense,
Mark
-----Original Message-----
From: Michael Kay
Sent: Saturday, December 11, 2010 4:42 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Combining two files
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
|