-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaq.html
131 lines (131 loc) · 7.96 KB
/
faq.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS4J FAQ</title>
<link href="faq-c.css" rel="stylesheet" type="text/css" />
<script src="js/faq-a.js" type="text/javascript" charset="utf-8"></script>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body id="faq">
<div class="layout">
<div id="hdr01"></div>
<a id="mylinkhome" href="/"><span>CSS4J</span></a>
</div>
<div class="container">
<div class="menu">
<ul class="menulist">
<li><a id="mnuindice" href="/"><span>Home</span></a></li>
<li><a id="mnuusage" href="usage.html"><span>Usage</span></a></li>
<li><a id="mnuapi2" href="api/latest/"><span>Latest API</span></a></li>
<li><div id="mnufaq-sel"><span>FAQ</span></div></li>
<li><a id="mnubenchmarks" href="benchmarks.html"><span>Benchmarks</span></a></li>
<li><a id="mnugithub" href="https://github.com/css4j"><span>Github</span></a></li>
</ul>
</div>
<div class="beforemain"></div>
<div class="main">
<div id="presentacion_top" class="textheader"><span>FAQ</span></div>
<div class="cos">
<h2>CSS4J FAQ</h2>
<p class="faqlisthelp" id="faqlisthelp">Click on the question to see the answer.</p>
<div class="faqlist" id="faqlist">
<div id="nsac">
<h4>What is NSAC?</h4>
<p>NSAC is a low-level event API for CSS parsing, an evolution of W3C's <a href="http://www.w3.org/Style/CSS/SAC/">SAC</a>. <a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/nsac/package-summary.html">NSAC 2.x</a> is not backwards-compatible
with SAC, but similar enough that migrating from it should be relatively easy (if you require compatibility with SAC, you may still use <a href="api/1.x/io.sf.carte.css4j/io/sf/carte/doc/style/css/nsac/package-summary.html">version 1 of NSAC</a>, shipped with css4j 1.x).</p>
<p>However, most developers use the higher-level CSS Object Model and do not need to care about NSAC except when handling <a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/CSSVarValue.html#getFallback()"><code>var()</code> fallback values</a>
or the <code>var()</code>-related <a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/CSSLexicalValue.html"><code>CSSLexicalValue</code></a>.</p>
</div>
<div id="cssvalue">
<h4>Are W3C's <code>CSSValue</code> and <code>CSSPrimitiveValue</code> interfaces supported?</h4>
<p>That API was <a href="https://lists.w3.org/Archives/Public/www-style/2003Oct/0347.html">deprecated by W3C</a>
but version 1.0 does implement them. Version 2 and later uses those names but the actual interfaces are different and
not backwards-compatible.</p>
</div>
<div id="getstylesheets">
<h4>How do I access the document style sheets?</h4>
<p>The <a href="https://www.w3.org/TR/cssom-1/#document-css-style-sheets">document style sheets</a> are a collection of style sheets
associated with the document. W3C's DOM Level 2 Style standard provides the <code><a href="https://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/stylesheets.html#StyleSheets-StyleSheet-DocumentStyle">DocumentStyle</a></code>
interface for that, see also <a href="https://www.w3.org/TR/cssom-1/#extensions-to-the-document-interface">Extensions to the Document Interface</a> in the more modern CSSOM.
That is, just use <code><a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/CSSDocument.html#getStyleSheets()">document.getStyleSheets()</a></code> to get the list of style sheets.</p>
</div>
<div id="getstylesheet">
<h4>Can I get the merged style sheet that applies to the document?</h4>
<p>The <code><a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/CSSDocument.html#getStyleSheet()">document.getStyleSheet()</a></code> method does that.
Although you can add style rules to it, you may consider using overriden styles or the user-defined style sheet
(neither are included in the sheet returned by that method) instead.</p>
</div>
<div id="clearrules">
<h4>How can I remove all the rules in a style sheet?</h4>
<p>Use <code>sheet.getCssRules().<a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/CSSRuleList.html#clear()">clear()</a></code>.</p>
</div>
<div id="cssomparser">
<h4>What is the difference between <code>CSSParser</code> and <code>CSSOMParser</code>? [2.0 or higher]</h4>
<p>When parsing media queries, the <code><a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/om/CSSOMParser.html">CSSOMParser</a></code>
class has an object-model internal <a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/MediaQueryFactory.html">factory</a>
that directly produces CSSOM-enabled media queries, while <code><a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/parser/CSSParser.html">CSSParser</a></code>
has a -less useful- factory based on NSAC lexical units.</p>
<p>If you want to parse media queries you probably want to use <code>CSSOMParser</code>, otherwise <code>CSSParser</code> should be adequate.</p>
</div>
<div id="dom4jdepend">
<h4>Does css4j depend on dom4j?</h4>
<p>The core module does not, but <a href="https://github.com/css4j/css4j-dom4j/">css4j-dom4j</a> is one of the available
DOM back-ends (and that one does depend on dom4j).</p>
</div>
<div id="dom4j12">
<h4>Does css4j-dom4j work with dom4j 1.x or 2.x?</h4>
<p>Although the provided Maven build requires dom4j 2.x, the resulting jar file can be used in runtime with 1.x too. Css4j-dom4j makes no use of the
methods that dom4j implements in 2.x but not in 1.6, so it is safe to use with 1.6. Recent versions aren't tested with 1.6 however.</p>
</div>
<div id="dom4jbase">
<h4>Using the dom4j back-end prior to version 3.1, I find that dom4j does not support using the document's uri to retrieve relative urls. How can I work around?</h4>
<p>You can manually set the base url, doing something like:</p>
<pre>
if (document.getBaseURL() == null) {
document.setBaseURL(baseUrl);
}
</pre>
<p>From version 3.1 onwards, the css4j-dom4j module does implement and support <code>Document.setDocumentURI()</code>.</p>
</div>
<div id="dom4janddomwrapper">
<h4>Does the DOM4J back-end make use of the DOM wrapper, internally?</h4>
<p>No, they are independent back-ends.</p>
</div>
<div id="doc4print">
<h4>How do I set up my document for computing paged-media styles?</h4>
<p>Use <code>document.setTargetMedium("print")</code> and then compute the styles. <code>setTargetMedium</code> rebuilds the style
cascade for the new medium.</p>
</div>
<div id="sdbnotfound">
<h4>I have set up a style database, but the library complains about missing it.</h4>
<p>Be sure to call <code>document.setTargetMedium("medium")</code>, where the medium
must be the same for which the style database was set.</p>
</div>
<div id="styledb">
<h4>The style database is an abstraction that supplies initial values for properties that are User Agent-dependent. Why not just set them at the UA style sheet?</h4>
<p>The <a href="usage.html#cascade">user agent sheet</a> depends on the document type and is not always loaded, while the <a href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/StyleDatabase.html">style database</a>
is document-independent (but medium-specific).</p>
</div>
<div id="minify">
<h4>Can this library be used as a general-purpose CSS minifier?</h4>
<p>This library's support for minification (the <code><a
href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/util/Minify.html">Minify</a></code>
class, or methods like <code><a
href="api/latest/io.sf.carte.css4j/io/sf/carte/doc/style/css/om/AbstractStyleSheet.html#toMinifiedString()">toMinifiedString()</a></code>
and the various <code>getMinifiedCssText()</code>) will not produce output of the smallest size,
but should be significantly more reliable than alternatives like YUI Compressor.</p>
<p>See also the part about <a href="usage.html#minification">minification in the Usage Guide</a>.</p>
</div>
<div id="mavencentral">
<h4>Are this project's artifacts available on Maven Central?</h4>
<p>No, as <a href="https://groups.google.com/g/css4j/c/op5jIoINb3M/m/IiiN-LfkDAAJ">this project does not accept Maven Central's terms of use</a>.</p>
</div>
</div>
</div>
<div class="footnote">
</div>
</div>
</div>
</body>
</html>