Merge the excellent documentation work done during foss4g into trunk. Many
thanks to all the contributors who helped put this together. I'm not exactly sure of what's going to happen with this, but for now, at http://openlayers.org/dev/doc/examples.html you can see links to all the examples *with descriptions*. Hooray! git-svn-id: http://svn.openlayers.org/trunk/openlayers@5362 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -28,21 +28,21 @@
|
||||
ul li {
|
||||
padding-left: 0;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
<script src="../lib/Firebug/firebug.js" type="text/javascript"></script>
|
||||
<script src="../lib/OpenLayers.js" type="text/javascript"></script>
|
||||
<script type="text/javascript">
|
||||
//<![CDATA[
|
||||
|
||||
|
||||
var format = new OpenLayers.Format.XML();
|
||||
var doc = null;
|
||||
|
||||
|
||||
function init() {
|
||||
var url = "xml/features.xml";
|
||||
OpenLayers.loadURL(url, null, null, loadSuccess, loadFailure);
|
||||
}
|
||||
|
||||
|
||||
function loadSuccess(request) {
|
||||
updateStatus("loaded");
|
||||
if(!request.responseXML.documentElement) {
|
||||
@@ -51,11 +51,11 @@
|
||||
doc = request.responseXML;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function loadFailure(request) {
|
||||
updateStatus("failed to load");
|
||||
}
|
||||
|
||||
|
||||
function updateStatus(msg) {
|
||||
document.getElementById("loadStatus").firstChild.nodeValue = msg;
|
||||
}
|
||||
@@ -63,12 +63,12 @@
|
||||
function updateOutput(text) {
|
||||
document.getElementById("output").firstChild.nodeValue = text;
|
||||
}
|
||||
|
||||
|
||||
function write() {
|
||||
var text = format.write(doc);
|
||||
updateOutput(text);
|
||||
}
|
||||
|
||||
|
||||
function getElementsByTagNameNS(node, uri, name) {
|
||||
var nodes = format.getElementsByTagNameNS(node, uri, name);
|
||||
var pieces = [];
|
||||
@@ -77,7 +77,7 @@
|
||||
}
|
||||
updateOutput(pieces.join(' '));
|
||||
}
|
||||
|
||||
|
||||
function hasAttributeNS(node, uri, name) {
|
||||
updateOutput(format.hasAttributeNS(node, uri, name))
|
||||
}
|
||||
@@ -92,7 +92,7 @@
|
||||
var attributeValue = format.getAttributeNS(node, uri, name);
|
||||
updateOutput('"' + attributeValue + '"')
|
||||
}
|
||||
|
||||
|
||||
function createElementNS(uri, name) {
|
||||
var node = format.createElementNS(uri, name);
|
||||
doc.documentElement.appendChild(node);
|
||||
@@ -106,40 +106,52 @@
|
||||
}
|
||||
|
||||
window.onload = init;
|
||||
|
||||
|
||||
//]]>
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h3>OpenLayers XML Example</h3>
|
||||
<p>OpenLayers has a very simple XML format class (OpenLayers.Format.XML)
|
||||
that can be used to read/write XML docs. The methods available on the
|
||||
XML format (or parser if you like) allow for reading and writing of the
|
||||
various XML flavors used by the library - in particular the vector data
|
||||
formats. It is by no means intended to be a full-fledged XML toolset.
|
||||
Additional methods will be added only as needed elsewhere in the
|
||||
library.</p>
|
||||
<p>This page loads an XML document and demonstrates a few of the methods
|
||||
available in the parser.</p>
|
||||
<p>Status: <b>XML document <span id="loadStatus">loading..</span>.</b></p>
|
||||
<p>After the XML document loads, see the result of a few of the methods
|
||||
below. Assume that you start with the following code:
|
||||
<br />
|
||||
<span class="code">
|
||||
var format = new OpenLayers.Format.XML();
|
||||
</span>
|
||||
</p>
|
||||
Sample methods
|
||||
<ul>
|
||||
<li><a href="javascript:void write();">format.write()</a> - write the XML doc as text</li>
|
||||
<li><a href="javascript:void getElementsByTagNameNS(doc, 'http://www.opengis.net/gml', 'MultiPolygon');">format.getElementsByTagNameNS()</a> - get all gml:MultiPolygon</li>
|
||||
<li><a href="javascript:void hasAttributeNS(doc.documentElement, 'http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');">format.hasAttributeNS()</a> - test to see schemaLocation attribute exists in the http://www.w3.org/2001/XMLSchema-instance namespace</li>
|
||||
<li><a href="javascript:void getAttributeNodeNS(doc.documentElement, 'http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');">format.getAttributeNodeNS()</a> - get schemaLocation attribute in the http://www.w3.org/2001/XMLSchema-instance namespace</li>
|
||||
<li><a href="javascript:void getAttributeNS(doc.documentElement, 'http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');">format.getAttributeNS()</a> - get schemaLocation attribute value in the http://www.w3.org/2001/XMLSchema-instance namespace</li>
|
||||
<li><a href="javascript:void createElementNS('http://bar.com/foo', 'foo:TestNode');">format.createElementNS()</a> - create a foo:TestNode element (and append it to the doc)</li>
|
||||
<li><a href="javascript:void createTextNode('test text ');">format.createTextNode()</a> - create a text node (and append it to the doc)</li>
|
||||
</ul>
|
||||
Output:
|
||||
<div id="output"> </div>
|
||||
<h1 id="title">XML Format Example</h1>
|
||||
|
||||
<div id="tags">
|
||||
</div>
|
||||
|
||||
<p id="shortdesc">
|
||||
Shows the use of the OpenLayers XML format class
|
||||
</p>
|
||||
|
||||
<div id="docs">
|
||||
<p>OpenLayers has a very simple XML format class (OpenLayers.Format.XML)
|
||||
that can be used to read/write XML docs. The methods available on the
|
||||
XML format (or parser if you like) allow for reading and writing of the
|
||||
various XML flavors used by the library - in particular the vector data
|
||||
formats. It is by no means intended to be a full-fledged XML toolset.
|
||||
Additional methods will be added only as needed elsewhere in the
|
||||
library.</p>
|
||||
<p>This page loads an XML document and demonstrates a few of the methods
|
||||
available in the parser.</p>
|
||||
<p>Status: <b>XML document <span id="loadStatus">loading..</span>.</b></p>
|
||||
<p>After the XML document loads, see the result of a few of the methods
|
||||
below. Assume that you start with the following code:
|
||||
<br />
|
||||
<span class="code">
|
||||
var format = new OpenLayers.Format.XML();
|
||||
</span>
|
||||
</p>
|
||||
Sample methods
|
||||
<ul>
|
||||
<li><a href="javascript:void write();">format.write()</a> - write the XML doc as text</li>
|
||||
<li><a href="javascript:void getElementsByTagNameNS(doc, 'http://www.opengis.net/gml', 'MultiPolygon');">format.getElementsByTagNameNS()</a> - get all gml:MultiPolygon</li>
|
||||
<li><a href="javascript:void hasAttributeNS(doc.documentElement, 'http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');">format.hasAttributeNS()</a> - test to see schemaLocation attribute exists in the http://www.w3.org/2001/XMLSchema-instance namespace</li>
|
||||
<li><a href="javascript:void getAttributeNodeNS(doc.documentElement, 'http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');">format.getAttributeNodeNS()</a> - get schemaLocation attribute in the http://www.w3.org/2001/XMLSchema-instance namespace</li>
|
||||
<li><a href="javascript:void getAttributeNS(doc.documentElement, 'http://www.w3.org/2001/XMLSchema-instance', 'schemaLocation');">format.getAttributeNS()</a> - get schemaLocation attribute value in the http://www.w3.org/2001/XMLSchema-instance namespace</li>
|
||||
<li><a href="javascript:void createElementNS('http://bar.com/foo', 'foo:TestNode');">format.createElementNS()</a> - create a foo:TestNode element (and append it to the doc)</li>
|
||||
<li><a href="javascript:void createTextNode('test text ');">format.createTextNode()</a> - create a text node (and append it to the doc)</li>
|
||||
</ul>
|
||||
Output:
|
||||
<div id="output"> </div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user