blob: 6759644f20e44fd3e08b2f79ca82c22e5ddf5353 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/*******************************************************************************
* Copyright (c) 2000, 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.help.internal.toc;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.eclipse.help.Node;
import org.eclipse.help.TocContribution;
import org.eclipse.help.internal.dynamic.NodeReader;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class TocFileParser extends DefaultHandler {
private NodeReader reader;
/*
* Parses the given toc XML file into model objects (a TocContribution).
*/
public TocContribution parse(TocFile tocFile) throws IOException, SAXException, ParserConfigurationException {
if (reader == null) {
reader = new NodeReader();
}
Node node = reader.read(tocFile.getInputStream());
TocContribution contribution = new TocContribution();
contribution.setCategoryId(tocFile.getCategory());
contribution.setContributorId(tocFile.getPluginId());
contribution.setExtraDocuments(DocumentFinder.collectExtraDocuments(tocFile));
contribution.setId(HrefUtil.normalizeHref(tocFile.getPluginId(), tocFile.getFile()));
contribution.setLocale(tocFile.getLocale());
contribution.setPrimary(tocFile.isPrimary());
contribution.setToc(node);
return contribution;
}
}
|