Révision 3716

TXM/trunk/bundles/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 3716)
169 169
				//pagedWriter.writeStartElement("ol");
170 170
				int i = 1;
171 171
				for (String note : notes) {
172
					note = note.trim()
172 173
					//pagedWriter.writeStartElement("li");
173 174
					pagedWriter.writeStartElement("a", ["href":"#noteref_"+i, "name":"note_"+i])
174 175
					pagedWriter.writeStartElement("sup")
175 176
					pagedWriter.writeCharacters(""+i)
176 177
					pagedWriter.writeEndElement() // </sub>
177 178
					pagedWriter.writeEndElement() // </a>
178
					pagedWriter.writeCharacters(note)
179
					
180
					if (note.startsWith("<") && note.endsWith(">")) {
181
						pagedWriter.write(note)
182
					} else {
183
						pagedWriter.writeCharacters(note)
184
					}
179 185
					pagedWriter.writeEmptyElement("br")
180 186
					i++;
181 187
				}
......
553 559
									firstWord = false;
554 560
									this.idxstart.add(wordid);
555 561
								}
562
								
563
								if (flagNote) {
564
									noteContent += "<w id=\""+wordid+"\">";
565
								}
556 566
								flagW = true
557 567
								break;
558 568
							default:
......
688 698
									pagedWriter.writeCharacters(wordvalue)
689 699
									pagedWriter.writeEndElement()
690 700
								} else {
691
									
701
									noteContent += "</w>";
692 702
								}
693 703
							//pagedWriter.writeComment("\n")
694 704
								lastword=wordvalue;
TXM/trunk/bundles/org.txm.core/src/java/org/txm/objects/Page.java (revision 3716)
43 43
 * The Class Page a fle to open in the Browser
44 44
 */
45 45
public class Page {
46
	
46

  
47 47
	/** The htmlfile. */
48 48
	protected File htmlfile;
49
	
49

  
50 50
	/** The edition. */
51 51
	protected Edition edition;
52
	
52

  
53 53
	/** The wordid. */
54 54
	protected String firstWordId;
55
	
55

  
56 56
	protected String name;
57
	
57

  
58 58
	protected int idx;
59
	
59

  
60 60
	/**
61 61
	 * Instantiates a new page.
62 62
	 *
63 63
	 * @param edition the edition
64
	 * @param name the page name
65
	 * @param wordid the page first word id
66
	 * @param i the page position
64
	 * @param name    the page name
65
	 * @param wordid  the page first word id
66
	 * @param i       the page position
67 67
	 * 
68 68
	 */
69 69
	public Page(Edition edition, String name, String wordid, int i) {
70

  
70 71
		this.edition = edition;
71 72
		this.name = name;
72 73
		this.firstWordId = wordid;
73 74
		this.htmlfile = new File(edition.getHtmlDir(), edition.getText().getName() + "_" + name + ".html");
74 75
		this.idx = i;
75 76
	}
76
	
77

  
77 78
	/**
78 79
	 * Retro-compatibility of import.xml file
79 80
	 * 
80 81
	 * @param e
81 82
	 */
82 83
	public void _load(Element e) {
84

  
83 85
		this.name = e.getAttribute("id");
84 86
		this.firstWordId = e.getAttribute("wordid");
85 87
	}
86
	
88

  
87 89
	/**
88 90
	 * Gets the word id.
89 91
	 *
90 92
	 * @return the word id
91 93
	 */
92 94
	public String getWordId() {
95

  
93 96
		return firstWordId;
94 97
	}
95
	
98

  
96 99
	/**
97 100
	 * Gets the edition.
98 101
	 *
......
101 104
	public Edition getEdition() {
102 105
		return edition;
103 106
	}
104
	
107

  
105 108
	public boolean equals(Page p) {
109

  
106 110
		return p.idx == this.idx && p.name.equals(this.name) && p.htmlfile.equals(this.htmlfile);
107 111
	}
108
	
112

  
109 113
	/**
110 114
	 * Gets the file.
111 115
	 *
......
114 118
	public File getFile() {
115 119
		return this.htmlfile;
116 120
	}
117
	
121

  
118 122
	/**
119 123
	 * To url.
120 124
	 *
......
123 127
	public String toURL() {
124 128
		try {
125 129
			return this.htmlfile.toURI().toURL().toString();
126
		}
127
		catch (MalformedURLException e) {
130
		} catch (MalformedURLException e) {
128 131
			System.err.println(NLS.bind(TXMCoreMessages.malformedURLFileP0, htmlfile));
129 132
			return ""; //$NON-NLS-1$
130 133
		}
131 134
	}
132
	
135

  
136
	public Page getNextPage() {
137

  
138
		return this.edition.getNextPage(this);
139
	}
140

  
141
	public Page getPreviousPage() {
142

  
143
		return this.edition.getPreviousPage(this);
144
	}
145

  
146
	public Page getFirstPage() {
147

  
148
		return this.edition.getFirstPage();
149
	}
150

  
151
	public Page getLastPage() {
152

  
153
		return this.edition.getLastPage();
154
	}
155

  
133 156
	/**
134
	 * Found first word id.
157
	 * 
158
	 * @return the next page word id or null if this page is the last page
159
	 */
160
	public String getLastWordID() {
161

  
162
		Page nextPage = getNextPage();
163
		if (this.equals(nextPage)) {
164
			return nextPage.getWordId();
165
		}
166
		return null;
167
	}
168

  
169
	/**
170
	 * Fint the first word id in a HTML Edition page
135 171
	 *
136 172
	 * @param page the page
137 173
	 * @return the string
138 174
	 * @throws Exception the exception
139 175
	 */
140
	public static String foundFirstWordId(File page) throws Exception {
176
	public static String findFirstWordIdInFile(File page) throws Exception {
177

  
141 178
		InputStream inputData;
142 179
		inputData = page.toURI().toURL().openStream();
143
		
180

  
144 181
		XMLInputFactory factory = XMLInputFactory.newInstance();
145 182
		XMLStreamReader parser = factory.createXMLStreamReader(inputData);
146
		
183

  
147 184
		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
148 185
			if (event == XMLStreamConstants.START_ELEMENT) {
149 186
				String localname = parser.getLocalName();
150
				if (localname.matches("span")) //$NON-NLS-1$
151
				{
187
				if (localname.matches("span")) { //$NON-NLS-1$
152 188
					String idattr = parser.getAttributeValue(null, "id"); //$NON-NLS-1$
153
					if (idattr != null)
154
						if (idattr.startsWith("w")) //$NON-NLS-1$
155
						{
156
						parser.close();
157
						inputData.close();
158
						return idattr;
189
					if (idattr != null) {
190
						if (idattr.startsWith("w")) { //$NON-NLS-1$
191
							parser.close();
192
							inputData.close();
193
							return idattr;
159 194
						}
195
					}
160 196
				}
161 197
			}
162 198
		}
......
164 200
		inputData.close();
165 201
		return null;
166 202
	}
167
	
203

  
168 204
	/**
169 205
	 * Sets the name.
170 206
	 *
171 207
	 * @param name the new name
172 208
	 */
173 209
	public void setName(String name) {
210

  
174 211
		this.name = name;
175 212
	}
176
	
213

  
177 214
	/**
178 215
	 * Sets the name.
179 216
	 *
180 217
	 * @param name the new name
181 218
	 */
182 219
	public void setWordId(String wordid) {
220

  
183 221
		this.firstWordId = wordid;
184 222
	}
185
	
223

  
186 224
	/*
187 225
	 * (non-Javadoc)
226
	 * 
188 227
	 * @see java.lang.Object#toString()
189 228
	 */
190 229
	@Override
191 230
	public String toString() {
231

  
192 232
		return "Page [name=" + name + ", htmlfile=" + htmlfile + ", firstWordId=" + firstWordId + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
193 233
	}
194
	
234

  
195 235
	public String getName() {
236

  
196 237
		return this.name;
197 238
	}
198 239
}
TXM/trunk/bundles/org.txm.core/src/java/org/txm/importer/Convert5To6.java (revision 3716)
201 201
			int pagecounter = 1;
202 202
			for (File page : htmlfiles) {
203 203
				if (page.getName().startsWith(textname)) {
204
					String firstwordid  = Page.foundFirstWordId(page);
204
					String firstwordid  = Page.findFirstWordIdInFile(page);
205 205
					params.addPage(editionElem, ""+pagecounter++, firstwordid); //$NON-NLS-1$
206 206
				}
207 207
			}
......
213 213
				pagecounter = 1;
214 214
				for (File page : htmlfiles) {
215 215
					if (page.getName().startsWith(textname)) {
216
						String firstwordid  = Page.foundFirstWordId(page);
216
						String firstwordid  = Page.findFirstWordIdInFile(page);
217 217
						params.addPage(editionElem, ""+pagecounter++, firstwordid); //$NON-NLS-1$
218 218
					}
219 219
				}

Formats disponibles : Unified diff