6378099: RFE: Use libfontconfig to create/synthesise a fontconfig.properties
Reviewed-by: tdv, igor
<?xml version="1.0" encoding="UTF-8"?><!--Copyright 2003-2005 Sun Microsystems, Inc. All Rights Reserved.DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.This code is free software; you can redistribute it and/or modify itunder the terms of the GNU General Public License version 2 only, aspublished by the Free Software Foundation. Sun designates thisparticular file as subject to the "Classpath" exception as providedby Sun in the LICENSE file that accompanied this code.This code is distributed in the hope that it will be useful, but WITHOUTANY WARRANTY; without even the implied warranty of MERCHANTABILITY orFITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public Licenseversion 2 for more details (a copy is included in the LICENSE file thataccompanied this code).You should have received a copy of the GNU General Public License version2 along with this work; if not, write to the Free Software Foundation,Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,CA 95054 USA or visit www.sun.com if you need additional information orhave any questions.--><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>javax.xml.xpath</title><meta name="@author" content="mailto:Ben@galbraiths.org" /><meta name="@author" content="mailto:Norman.Walsh@Sun.com" /><meta name="@author" content="mailto:Jeff.Suttor@Sun.com" /><meta name="@version" content="$Revision: 1.3 $, $Date: 2005/11/03 19:34:17 $" /><meta name="@see" content="http://www.w3.org/TR/xpath" /><meta name="@since" content="1.5" /></head><body><p>This package provides an <em>object-model neutral</em> API for theevaluation of XPath expressions and access to the evaluationenvironment.</p><p>The following XML standards apply:</p><ul><li><a href="http://www.w3.org/TR/xpath">XML Path Language (XPath) Version 1.0</a></li></ul><hr /><h2>XPath Overview</h2><p>The XPath language provides a simple, concise syntax for selectingnodes from an XML document. XPath also provides rules for converting anode in an XML document object model (DOM) tree to a boolean, double,or string value. XPath is a W3C-defined language and an official W3Crecommendation; the W3C hosts the XML Path Language (XPath) Version1.0 specification.</p><p>XPath started in life in 1999 as a supplement to the XSLT andXPointer languages, but has more recently become popular as astand-alone language, as a single XPath expression can be used toreplace many lines of DOM API code.</p><h3>XPath Expressions</h3><p>An XPath <em>expression</em> is composed of a <em>locationpath</em> and one or more optional <em>predicates</em>. Expressionsmay also include XPath variables.</p><p>The following is an example of a simple XPath expression:</p><pre>/foo/bar</pre><p>This example would select the <code><bar></code> element inan XML document such as the following:</p><pre><foo><bar/></foo></pre><p>The expression <code>/foo/bar</code> is an example of a locationpath. While XPath location paths resemble Unix-style file systempaths, an important distinction is that XPath expressions return<em>all</em> nodes that match the expression. Thus, all three<code><bar></code> elements in the following document would beselected by the <code>/foo/bar</code> expression:</p><pre><foo><bar/><bar/><bar/></foo></pre><p>A special location path operator, <code>//</code>, selects nodes atany depth in an XML document. The following example selects all<code><bar></code> elements regardless of their location in adocument:</p><pre>//bar</pre><p>A wildcard operator, *, causes all element nodes to be selected.The following example selects all children elements of a<code><foo></code> element:</p><pre>/foo/*</pre><p>In addition to element nodes, XPath location paths may also addressattribute nodes, text nodes, comment nodes, and processing instructionnodes. The following table gives examples of location paths for eachof these node types:</p><table border="1"><tr><td>Location Path</td><td>Description</td></tr><tr><td><code>/foo/bar/<strong>@id</strong></code></td><td>Selects the attribute <code>id</code> of the <code><bar></code> element</td></tr><tr><td><code>/foo/bar/<strong>text()</strong></code></td><td>Selects the text nodes of the <code><bar></code> element. Nodistinction is made between escaped and non-escaped character data.</td></tr><tr><td><code>/foo/bar/<strong>comment()</strong></code></td><td>Selects all comment nodes contained in the <code><bar></code> element.</td></tr><tr><td><code>/foo/bar/<strong>processing-instruction()</strong></code></td><td>Selects all processing-instruction nodes contained in the<code><bar></code> element.</td></tr></table><p>Predicates allow for refining the nodes selected by an XPathlocation path. Predicates are of the form<code>[<em>expression</em>]</code>. The following example selects all<code><foo></code> elements that contain an <code>include</code>attribute with the value of <code>true</code>:</p><pre>//foo[@include='true']</pre><p>Predicates may be appended to each other to further refine anexpression, such as:</p><pre>//foo[@include='true'][@mode='bar']</pre><h3>Using the XPath API</h3><p>The following example demonstrates using the XPath API to select oneor more nodes from an XML document:</p><pre>XPath xpath = XPathFactory.newInstance().newXPath();String expression = "/widgets/widget";InputSource inputSource = new InputSource("widgets.xml");NodeList nodes = (NodeList) xpath.evaluate(expression, inputSource, XPathConstants.NODESET);</pre><h3>XPath Expressions and Types</h3><p>While XPath expressions select nodes in the XML document, the XPathAPI allows the selected nodes to be coalesced into one of thefollowing other data types:</p><ul><li><code>Boolean</code></li><li><code>Number</code></li><li><code>String</code></li></ul><p>The desired return type is specified by a {@linkjavax.xml.namespace.QName} parameter in method call used to evaluatethe expression, which is either a call to<code>XPathExpression.evalute(...)</code> or to one of the<code>XPath.evaluate(...)</code> convenience methods. The allowedQName values are specified as constants in the {@linkjavax.xml.xpath.XPathConstants} class; they are:</p><ul><li>{@link javax.xml.xpath.XPathConstants#NODESET}</li><li>{@link javax.xml.xpath.XPathConstants#NODE}</li><li>{@link javax.xml.xpath.XPathConstants#STRING}</li><li>{@link javax.xml.xpath.XPathConstants#BOOLEAN}</li><li>{@link javax.xml.xpath.XPathConstants#NUMBER}</li></ul><p>When a <code>Boolean</code> return type is requested,<code>Boolean.TRUE</code> is returned if one or more nodes wereselected; otherwise, <code>Boolean.FALSE</code> is returned.</p><p>The <code>String</code> return type is a convenience for retrievingthe character data from a text node, attribute node, comment node, orprocessing-instruction node. When used on an element node, the valueof the child text nodes is returned.</p><p>The <code>Number</code> return type attempts to coalesce the textof a node to a <code>double</code> data type.</p><h3>XPath Context</h3><p>XPath location paths may be relative to a particular node in thedocument, known as the <code>context</code>. Consider the followingXML document:</p><pre><widgets><widget><manufacturer/><dimensions/></widget></widgets></pre><p>The <code><widget></code> element can be selected with thefollowing XPath API code:</p><pre>// parse the XML as a W3C DocumentDocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();Document document = builder.parse(new File("/widgets.xml"));XPath xpath = XPathFactory.newInstance().newXPath();String expression = "/widgets/widget";Node widgetNode = (Node) xpath.evaluate(expression, document, XPathConstants.NODE);</pre><p>With a reference to the <code><widget></code> element, arelative XPath expression can now written to select the<code><manufacturer></code> child element:</p><pre>XPath xpath = XPathFactory.newInstance().newXPath();<strong>String expression = "manufacturer";</strong>Node manufacturerNode = (Node) xpath.evaluate(expression, <strong>widgetNode</strong>, XPathConstants.NODE);</pre><ul><li>Author <a href="mailto:Ben@galbraiths.org">Ben Galbraith</a></li><li>Author <a href="mailto:Norman.Walsh@Sun.com">Norman Walsh</a></li><li>Author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a></li><li>See <a href="http://www.w3.org/TR/xpath">XML Path Language (XPath) Version 1.0</a></li><li>Since 1.5</li></ul> </body></html>