@@ -285,7 +285,8 @@ <h2>Examples with DOM4J</h2>
285
285
but you do not need the latter unless you plan to use the DOM4J agent.</ p >
286
286
< p > For example, with Gradle:</ p >
287
287
< pre class ="code "> < code class ="language-groovy "> dependencies {
288
- api "io.sf.carte:css4j-dom4j:${css4jDom4jVersion}"
288
+ implementation "io.sf.carte:css4j-dom4j:${css4jDom4jVersion}"
289
+ implementation "io.sf.carte:xml-dtd:4.2"
289
290
}
290
291
</ code > </ pre >
291
292
< p > But please remember that you have to set up css4j's repository, if you haven't already:</ p >
@@ -305,11 +306,19 @@ <h2>Examples with DOM4J</h2>
305
306
}
306
307
</ code > </ pre >
307
308
< p > Same with Apache Maven:</ p >
308
- < pre class ="code "> < code class ="language-xml "> <dependency>
309
+ < pre class ="code "> < code class ="language-xml "> <!-- This artifact requires the css4j Maven repository -->
310
+ <dependency>
309
311
<groupId>io.sf.carte</groupId>
310
312
<artifactId>css4j-dom4j</artifactId>
311
313
<version>${css4jDom4j.version}</version>
312
314
</dependency>
315
+
316
+ <!-- This artifact requires the css4j Maven repository -->
317
+ <dependency>
318
+ <groupId>io.sf.carte</groupId>
319
+ <artifactId>xml-dtd</artifactId>
320
+ <version>4.2</version>
321
+ </dependency>
313
322
</ code > </ pre >
314
323
< p > Again, please keep in mind adding css4j's Maven repository to your POM file:
315
324
</ p >
@@ -323,9 +332,13 @@ <h2>Examples with DOM4J</h2>
323
332
</ code > </ pre >
324
333
< p > The < code > css4j-dom4j</ code > artifact transitively implies the < code > css4j</ code > core module, but since both artifacts have
325
334
different release cycles you may want to add an explicit dependency for the core module, with the latest version.</ p >
326
- < p > As explained in the < a href ="#modules "> modules section</ a > , recent < code > css4j-dom4j</ code > artifacts are compatible with < code > css4j</ code >
327
- artifacts that have the same major version number, for example both < code > css4j-dom4j</ code > 3.5.2 and 3.6.0 are compatible with
328
- < code > css4j</ code > 3.9.1.</ p >
335
+ < p > As explained in the < a href ="#modules "> modules section</ a > , recent < code > css4j-dom4j</ code > artifacts are
336
+ compatible with < code > css4j</ code > artifacts that have the same major version number, for example both
337
+ < code > css4j-dom4j</ code > 3.5.2 and 3.6.0 are compatible with < code > css4j</ code > 3.9.1.</ p >
338
+ < p > If your project is modular you will need this:</ p >
339
+ < pre class ="code "> < code class ="language-java "> requires io.sf.carte.css4j.dom4j;
340
+ requires io.sf.carte.xml.dtd; // Only if you use DefaultEntityResolver
341
+ </ code > </ pre >
329
342
< h3 class ="subtema " id ="dom4j-parsing "> Loading and parsing an XML document</ h3 >
330
343
< p > This is the easiest way to parse an XML document to use this package with DOM4J, using that library's < code > SAXReader</ code > :</ p >
331
344
< pre class ="code "> < code class ="language-java "> SAXReader reader = new SAXReader(XHTMLDocumentFactory.getInstance());
@@ -334,7 +347,10 @@ <h3 class="subtema" id="dom4j-parsing">Loading and parsing an XML document</h3>
334
347
XHTMLDocument document = (XHTMLDocument) reader.read(re);
335
348
</ code > </ pre >
336
349
< p > As you see, a document factory called < a class ="codeitem " href ="api/latest/io.sf.carte.css4j.dom4j/io/sf/carte/doc/dom4j/XHTMLDocumentFactory.html "> XHTMLDocumentFactory</ a >
337
- is used.</ p >
350
+ is used. And as mentioned previously, the < a class ="codeitem " href =
351
+ "api/latest/io.sf.carte.xml.dtd/io/sf/carte/doc/xml/dtd/DefaultEntityResolver.html "> DefaultEntityResolver</ a >
352
+ class is provided by the < a href ="https://github.com/css4j/xml-dtd "> < code > xml-dtd</ code > </ a >
353
+ project.</ p >
338
354
< p > Once you got the element you want the computed style for (see, for example, the
339
355
< a href ="https://github.com/dom4j/dom4j/wiki/Quick-Start-Guide " target ="_blank "> DOM4J Quick Start Guide</ a > ), just get it with a procedure analogous to the
340
356
< a href ="https://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-ViewCSS " target ="_blank "> < code > ViewCSS</ code > </ a >
0 commit comments