100% found this document useful (2 votes)
11 views

Java XML and JSON Friesen Jeff download

The document provides information about the book 'Java XML and JSON' by Jeff Friesen, which focuses on processing XML and JSON in Java. It includes details about the book's content, such as chapters on XML parsing, creating XML documents, and working with JSON using various libraries. The document also contains links for downloading the book and related resources.

Uploaded by

elzerthies2u
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
11 views

Java XML and JSON Friesen Jeff download

The document provides information about the book 'Java XML and JSON' by Jeff Friesen, which focuses on processing XML and JSON in Java. It includes details about the book's content, such as chapters on XML parsing, creating XML documents, and working with JSON using various libraries. The document also contains links for downloading the book and related resources.

Uploaded by

elzerthies2u
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 63

Java XML and JSON Friesen Jeff download

https://textbookfull.com/product/java-xml-and-json-friesen-jeff/

Download more ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Java XML and JSON: Document Processing for Java SE Jeff


Friesen

https://textbookfull.com/product/java-xml-and-json-document-
processing-for-java-se-jeff-friesen/

Java XML and JSON: Document Processing for Java SE 2nd


Edition Jeff Friesen

https://textbookfull.com/product/java-xml-and-json-document-
processing-for-java-se-2nd-edition-jeff-friesen/

Learn Java for Android Development Friesen Jeff

https://textbookfull.com/product/learn-java-for-android-
development-friesen-jeff/

Pro RESTful APIs: Design, Build and Integrate with


REST, JSON, XML and JAX-RS Patni

https://textbookfull.com/product/pro-restful-apis-design-build-
and-integrate-with-rest-json-xml-and-jax-rs-patni/
The LEGO Castle Book Build Your Own Mini Medieval World
1st Edition Jeff Friesen

https://textbookfull.com/product/the-lego-castle-book-build-your-
own-mini-medieval-world-1st-edition-jeff-friesen/

Beginning XML with C# 7: XML Processing and Data Access


for C# Developers 2nd Edition Bipin Joshi (Auth.)

https://textbookfull.com/product/beginning-xml-with-c-7-xml-
processing-and-data-access-for-c-developers-2nd-edition-bipin-
joshi-auth/

C# and XML Primer 1st Edition Jonathan Hartwell (Auth.)

https://textbookfull.com/product/c-and-xml-primer-1st-edition-
jonathan-hartwell-auth/

Cybersecurity Law Jeff Kosseff

https://textbookfull.com/product/cybersecurity-law-jeff-kosseff/

International Financial Management Jeff Madura

https://textbookfull.com/product/international-financial-
management-jeff-madura/
T HE E X P ER T ’S VOIC E ® IN JAVA

Java XML
and JSON

Jeff Friesen
Java XML and JSON

Jeff Friesen
Java XML and JSON
Jeff Friesen
Dauphin, Manitoba, Canada
ISBN-13 (pbk): 978-1-4842-1915-7 ISBN-13 (electronic): 978-1-4842-1916-4
DOI 10.1007/978-1-4842-1916-4
Library of Congress Control Number: 2016943840
Copyright © 2016 by Jeff Friesen
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part
of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations,
recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission
or information storage and retrieval, electronic adaptation, computer software, or by similar or
dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are
brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for
the purpose of being entered and executed on a computer system, for exclusive use by the purchaser
of the work. Duplication of this publication or parts thereof is permitted only under the provisions
of the Copyright Law of the Publisher’s location, in its current version, and permission for use must
always be obtained from Springer. Permissions for use may be obtained through RightsLink at the
Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol
with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only
in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of
the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they
are not identified as such, is not to be taken as an expression of opinion as to whether or not they are
subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal responsibility
for any errors or omissions that may be made. The publisher makes no warranty, express or implied,
with respect to the material contained herein.
Managing Director: Welmoed Spahr
Lead Editor: Steve Anglin
Technical Reviewer: Wallace Jackson
Editorial Board: Steve Anglin, Pramila Balan, Louise Corrigan, James T. DeWolf,
Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, James Markham,
Susan McDermott, Matthew Moodie, Ben Renow-Clarke, Gwenan Spearing
Coordinating Editor: Mark Powers
Copy Editor: Mary Behr
Compositor: SPi Global
Indexer: SPi Global
Artist: SPi Global
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail [email protected], or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales.
Any source code or other supplementary materials referenced by the author in this text is available
to readers at www.apress.com/9781484219157. For detailed information about how to locate your
book’s source code, go to www.apress.com/source-code/. Readers can also access source code at
SpringerLink in the Supplementary Material section for each chapter.
Printed on acid-free paper
To Dave, the late Father Lucian, Jane, and Rob.
Contents at a
Glance
About the Author ............................................................................ xiii
About the Technical Reviewer ..........................................................xv
Acknowledgments ..........................................................................xvii
Introduction .....................................................................................xix

■Chapter 1: Introducing XML ............................................................ 1


■Chapter 2: Parsing XML Documents with SAX.............................. 29
■Chapter 3: Parsing and Creating XML Documents with DOM ....... 57
■Chapter 4: Parsing and Creating XML Documents with StAX ....... 75
■Chapter 5: Selecting Nodes with XPath ........................................ 97
■Chapter 6: Transforming XML Documents with XSLT ................. 119
■Chapter 7: Introducing JSON ...................................................... 133
■Chapter 8: Parsing and Creating JSON Objects with mJson.......... 149
■Chapter 9: Parsing and Creating JSON Objects with Gson ......... 179

v
vi Contents at a Glance

■Chapter 10: Extracting JSON Values with JsonPath ................... 223


■Appendix A: Answers to Exercises ............................................ 241

Index .............................................................................................. 279


Contents
About the Author ............................................................................ xiii
About the Technical Reviewer ..........................................................xv
Acknowledgments ..........................................................................xvii
Introduction .....................................................................................xix

■Chapter 1: Introducing XML ............................................................ 1


What Is XML? .......................................................................................... 1
Language Features Tour .......................................................................... 3
XML Declaration ....................................................................................................... 3
Elements and Attributes ........................................................................................... 5
Character References and CDATA Sections .............................................................. 7
Namespaces ............................................................................................................. 8
Comments and Processing Instructions ................................................................. 13

Well-Formed Documents ....................................................................... 14


Valid Documents ................................................................................... 15
Document Type Definition ....................................................................................... 15
XML Schema........................................................................................................... 21

Summary ............................................................................................... 28

vii
viii Contents

■Chapter 2: Parsing XML Documents with SAX.............................. 29


What Is SAX? ......................................................................................... 29
Exploring the SAX API ............................................................................ 30
Obtaining a SAX 2 Parser........................................................................................ 30
Touring XMLReader Methods.................................................................................. 31
Touring the Handler and Resolver Interfaces.......................................................... 35

Demonstrating the SAX API ................................................................... 40


Creating a Custom Entity Resolver ........................................................ 49
Summary ............................................................................................... 54
■Chapter 3: Parsing and Creating XML Documents with DOM ....... 57
What Is DOM? ........................................................................................ 57
A Tree of Nodes ..................................................................................... 58
Exploring the DOM API........................................................................... 61
Obtaining a DOM Parser/Document Builder............................................................ 61
Parsing and Creating XML Documents ................................................................... 63

Demonstrating the DOM API .................................................................. 67


Summary ............................................................................................... 74
■Chapter 4: Parsing and Creating XML Documents with StAX ....... 75
What Is StAX? ........................................................................................ 75
Exploring StAX ....................................................................................... 76
Parsing XML Documents......................................................................................... 77
Creating XML Documents ....................................................................................... 85

Summary ............................................................................................... 95
■Chapter 5: Selecting Nodes with XPath ........................................ 97
What Is XPath? ...................................................................................... 97
XPath Language Primer ......................................................................... 97
Location Path Expressions...................................................................................... 98
General Expressions ............................................................................................. 101
Contents ix

XPath and DOM ................................................................................... 103


Advanced XPath .................................................................................. 110
Namespace Contexts ............................................................................................ 110
Extension Functions and Function Resolvers ....................................................... 111
Variables and Variable Resolvers.......................................................................... 115
Summary ............................................................................................. 118
■Chapter 6: Transforming XML Documents with XSLT ................. 119
What Is XSLT? ...................................................................................... 119
Exploring the XSLT API......................................................................... 120
Demonstrating the XSLT API ................................................................ 123
Summary ............................................................................................. 132
■Chapter 7: Introducing JSON ...................................................... 133
What Is JSON? ..................................................................................... 133
JSON Syntax Tour ................................................................................ 134
Demonstrating JSON with JavaScript ................................................. 137
Validating JSON Objects ...................................................................... 140
Summary ............................................................................................. 147
■Chapter 8: Parsing and Creating JSON Objects with mJson.......... 149
What Is mJson? ................................................................................... 149
Obtaining and Using mJson .................................................................................. 150

Exploring the Json Class ..................................................................... 150


Creating Json Objects........................................................................................... 151
Learning About Json Objects ................................................................................ 155
Navigating Json Object Hierarchies...................................................................... 163
Modifying Json Objects ........................................................................................ 165
Validation .............................................................................................................. 170
Customization via Factories ................................................................................. 173

Summary ............................................................................................. 178


x Contents

■Chapter 9: Parsing and Creating JSON Objects with Gson ......... 179
What Is Gson? ..................................................................................... 179
Obtaining and Using Gson .................................................................................... 180

Exploring GSon .................................................................................... 180


Introducing the Gson Class ................................................................................... 181
Parsing JSON Objects Through Deserialization .................................................... 183
Creating JSON Objects Through Serialization ....................................................... 190
Learning More About Gson ................................................................................... 197

Summary ............................................................................................. 222


■Chapter 10: Extracting JSON Values with JsonPath ................... 223
What Is JsonPath? ............................................................................... 223
Learning the JsonPath Language ........................................................ 224
Obtaining and Using the JsonPath Library .......................................... 227
Exploring the JsonPath Library ........................................................... 228
Extracting Values from JSON Objects ................................................................... 229
Using Predicates to Filter Items............................................................................ 232

Summary ............................................................................................. 239


■Appendix A: Answers to Exercises ............................................ 241
Chapter 1: Introducing XML ................................................................. 241
Chapter 2: Parsing XML Documents with SAX..................................... 246
Chapter 3: Parsing and Creating XML Documents with DOM .............. 251
Chapter 4: Parsing and Creating XML Documents with StAX .............. 258
Chapter 5: Selecting Nodes with XPath ............................................... 261
Chapter 6: Transforming XML Documents with XSLT .......................... 264
Chapter 7: Introducing JSON ............................................................... 267
Contents xi

Chapter 8: Parsing and Creating JSON Objects with mJson ............... 269
Chapter 9: Parsing and Creating JSON Objects with Gson .................. 272
Chapter 10: Extracting JSON Property Values with JsonPath.............. 276

Index .............................................................................................. 279


About the Author
Jeff Friesen is a freelance teacher and
software developer with an emphasis on Java.
In addition to authoring Java I/O, NIO and NIO.2
(Apress) and Java Threads and the Concurrency
Utilities (Apress), Jeff has written numerous
articles on Java and other technologies
(such as Android) for JavaWorld (JavaWorld.com),
informIT (InformIT.com), Java.net, SitePoint
(SitePoint.com), and other web sites. Jeff can
be contacted via his web site at JavaJeff.ca.
or via his LinkedIn (LinkedIn.com) profile
(www.linkedin.com/in/javajeff).

xiii
About the Technical
Reviewer
Wallace Jackson has been writing for leading
multimedia publications about his work in new
media content development since the advent
of Multimedia Producer Magazine nearly two
decades ago. He has authored a half-dozen
Android book titles for Apress, including four
titles in the popular Pro Android series. Wallace
received his undergraduate degree in business
economics from the University of California
at Los Angeles and a graduate degree in MIS
design and implementation from the University
of Southern California. He is currently the CEO
of Mind Taffy Design, a new media content
production and digital campaign design and
development agency.

xv
Acknowledgments
Many people assisted me in the development of this book, and I thank them.
I especially thank Steve Anglin for asking me to write it and Mark Powers for
guiding me through the writing process.

xvii
Introduction
XML and (the more popular) JSON let you organize data in textual formats.
This book introduces you to these technologies along with Java APIs for
integrating them into your Java code. This book introduces you to XML and
JSON as of Java 8 update 60.
Chapter 1 introduces XML, where you learn about basic language features
(such as the XML declaration, elements and attributes, and namespaces).
You also learn about well-formed XML documents and how to validate them
via the Document Type Definition and XML Schema grammar languages.
Chapter 2 focuses on Java’s SAX API for parsing XML documents. You learn
how to obtain a SAX 2 parser; you then tour XMLReader methods along with
handler and entity resolver interfaces. Finally, you explore a demonstration
of this API and learn how to create a custom entity resolver.
Chapter 3 addresses Java’s DOM API for parsing and creating XML
documents. After discovering the various nodes that form a DOM document
tree, you explore the DOM API, where you learn how to obtain a DOM
parser/document builder and how to parse and create XML documents.
Chapter 4 places the spotlight on Java’s StAX API for parsing and creating
XML documents. You learn how to use StAX to parse XML documents with
stream-based and event-based readers, and how to create XML documents
with stream-based and event-based writers.
Moving on, Chapter 5 presents Java’s XPath API for simplifying access to
a DOM tree’s nodes. You receive a primer on the XPath language, learning
about location path expressions and general expressions. You also explore
advanced features starting with namespace contexts.
Chapter 6 completes my coverage of XML by targeting Java’s XSLT API. You
learn about transformer factories and transformers, and much more.

xix
xx Introduction

Chapter 7 switches gears to JSON. You receive an introduction to JSON,


take a tour of its syntax, explore a demonstration of JSON in a JavaScript
context (because Java doesn’t yet officially support JSON), and learn how to
validate JSON objects in the context of JSON Schema.
You’ll need to work with third-party libraries to parse and create JSON
documents. Chapter 8 introduces you to the mJson library. After learning
how to obtain and use mJson, you explore the Json class, which is the entry
point for working with mJSon.
Google has released an even more powerful library for parsing and creating
JSON documents. The Gson library is the focus of Chapter 9. In this chapter,
you learn how to parse JSON objects through deserialization, how to create
JSON objects through serialization, and much more.
Chapter 10 completes my coverage of JSON by presenting the JsonPath
API for performing XPath-like operations on JSON documents.
Each chapter ends with assorted exercises that are designed to help you
master the content. Along with long answers and true/false questions,
you must also perform programming exercises. Appendix A provides the
answers and solutions.
Thanks for purchasing this book. I hope you find it helpful in understanding
XML and JSON in a Java context.
—Jeff Friesen
(April, 2016)

Note You can download this book’s source code by pointing your web browser
to www.apress.com/9781484219157 and clicking the Source Code tab
followed by the Download Now link.
Chapter 1
Introducing XML
Applications commonly use XML documents to store and exchange data.
XML defines rules for encoding documents in a format that is both
human-readable and machine-readable. This chapter introduces XML, tours
the XML language features, and discusses well-formed and valid documents.

What Is XML?
XML (eXtensible Markup Language) is a metalanguage (a language used to
describe other languages) for defining vocabularies (custom markup languages),
which is the key to XML’s importance and popularity. XML-based vocabularies
(such as XHTML) let you describe documents in a meaningful way.
XML vocabulary documents are like HTML (see http://en.wikipedia.org/
wiki/HTML) documents in that they are text-based and consist of markup
(encoded descriptions of a document’s logical structure) and content
(document text not interpreted as markup). Markup is evidenced via tags
(angle bracket-delimited syntactic constructs) and each tag has a name.
Furthermore, some tags have attributes (name-value pairs).

Electronic supplementary material The online version of this chapter


(doi:10.1007/978-1-4842-1916-4_1) contains supplementary material, which is
available to authorized users.

© Jeff Friesen 2016 1


J. Friesen, Java XML and JSON, DOI 10.1007/978-1-4842-1916-4_1
2 CHAPTER 1: Introducing XML

Note XML and HTML are descendants of Standard Generalized Markup


Language (SGML), which is the original metalanguage for creating vocabularies.
XML is essentially a restricted form of SGML, while HTML is an application of
SGML. The key difference between XML and HTML is that XML invites you to
create your own vocabularies with its own tags and rules, whereas HTML gives
you a single precreated vocabulary with its own fixed set of tags and rules.
XHTML and other XML-based vocabularies are XML applications. XHTML was
created to be a cleaner implementation of HTML.

If you haven’t previously encountered XML, you might be surprised by its


simplicity and how closely its vocabularies resemble HTML. You don’t need
to be a rocket scientist to learn how to create an XML document. To prove
this to yourself, check out Listing 1-1.

Listing 1-1. XML-Based Recipe for a Grilled Cheese Sandwich

<recipe>
<title>
Grilled Cheese Sandwich
</title>
<ingredients>
<ingredient qty="2">
bread slice
</ingredient>
<ingredient>
cheese slice
</ingredient>
<ingredient qty="2">
margarine pat
</ingredient>
</ingredients>
<instructions>
Place frying pan on element and select medium heat. For each bread
slice, smear one pat of margarine on one side of bread slice. Place cheese
slice between bread slices with margarine-smeared sides away from the
cheese. Place sandwich in frying pan with one margarine-smeared side in
contact with pan. Fry for a couple of minutes and flip. Fry other side for a
minute and serve.
</instructions>
</recipe>

Listing 1-1 presents an XML document that describes a recipe for making
a grilled cheese sandwich. This document is reminiscent of an HTML
document in that it consists of tags, attributes, and content. However, that’s
CHAPTER 1: Introducing XML 3

where the similarity ends. Instead of presenting HTML tags such as <html>,
<head>, <img>, and <p>, this informal recipe language presents its own
<recipe>, <ingredients>, and other tags.

Note Although Listing 1-1’s <title> and </title> tags are also found in
HTML, they differ from their HTML counterparts. Web browsers typically display
the content between these tags in their title bars. In contrast, the content
between Listing 1-1’s <title> and </title> tags might be displayed as a
recipe header, spoken aloud, or presented in some other way, depending on the
application that parses this document.

Language Features Tour


XML provides several language features for use in defining custom markup
languages: XML declaration, elements and attributes, character references
and CDATA sections, namespaces, and comments and processing
instructions. You will learn about these language features in this section.

XML Declaration
An XML document usually begins with the XML declaration, which is special
markup telling an XML parser that the document is XML. The absence of the
XML declaration in Listing 1-1 reveals that this special markup isn’t mandatory.
When the XML declaration is present, nothing can appear before it.
The XML declaration minimally looks like <?xml version="1.0"?> in which
the nonoptional version attribute identifies the version of the XML
specification to which the document conforms. The initial version of this
specification (1.0) was introduced in 1998 and is widely implemented.

Note The World Wide Web Consortium (W3C), which maintains XML, released
version 1.1 in 2004. This version mainly supports the use of line-ending
characters used on EBCDIC platforms (see http://en.wikipedia.org/
wiki/EBCDIC) and the use of scripts and characters that are absent from
Unicode 3.2 (see http://en.wikipedia.org/wiki/Unicode). Unlike
XML 1.0, XML 1.1 isn’t widely implemented and should be used only by those
needing its unique features.
4 CHAPTER 1: Introducing XML

XML supports Unicode, which means that XML documents consist entirely
of characters taken from the Unicode character set. The document’s
characters are encoded into bytes for storage or transmission, and the
encoding is specified via the XML declaration’s optional encoding attribute.
One common encoding is UTF-8 (see http://en.wikipedia.org/wiki/UTF-8),
which is a variable-length encoding of the Unicode character set. UTF-8 is a
strict superset of ASCII (see http://en.wikipedia.org/wiki/ASCII), which
means that pure ASCII text files are also UTF-8 documents.

Note In the absence of the XML declaration or when the XML declaration’s
encoding attribute isn’t present, an XML parser typically looks for a special
character sequence at the start of a document to determine the document’s
encoding. This character sequence is known as the byte-order-mark (BOM) and
is created by an editor program (such as Microsoft Windows Notepad) when it
saves the document according to UTF-8 or some other encoding. For example,
the hexadecimal sequence EF BB BF signifies UTF-8 as the encoding. Similarly,
FE FF signifies UTF-16 big endian (see https://en.wikipedia.org/
wiki/UTF-16), FF FE signifies UTF-16 little endian, 00 00 FE FF signifies
UTF-32 big endian (see https://en.wikipedia.org/wiki/UTF-32), and
FF FE 00 00 signifies UTF-32 little endian. UTF-8 is assumed when no
BOM is present.

If you’ll never use characters apart from the ASCII character set, you can
probably forget about the encoding attribute. However, when your native
language isn’t English or when you’re called to create XML documents that
include non-ASCII characters, you need to properly specify encoding.
For example, when your document contains ASCII plus characters from
a non-English Western European language (such as ç, the cedilla used in
French, Portuguese, and other languages), you might want to choose
ISO-8859-1 as the encoding attribute’s value—the document will probably
have a smaller size when encoded in this manner than when encoded with
UTF-8. Listing 1-2 shows you the resulting XML declaration.

Listing 1-2. An Encoded Document Containing Non-ASCII Characters

<?xml version="1.0" encoding="ISO-8859-1"?>


<movie>
<name>Le Fabuleux Destin d'Amélie Poulain</name>
<language>français</language>
</movie>
CHAPTER 1: Introducing XML 5

The final attribute that can appear in the XML declaration is standalone.
This optional attribute, which is only relevant with DTDs (discussed later),
determines if there are external markup declarations that affect the
information passed from an XML processor (a parser) to the application.
Its value defaults to no, implying that there are, or may be, such declarations.
A yes value indicates that there are no such declarations. For more
information, check out “The standalone pseudo-attribute is only relevant if a
DTD is used” article at (www.xmlplease.com/xml/xmlquotations/standalone).

Elements and Attributes


Following the XML declaration is a hierarchical (tree) structure of elements,
where an element is a portion of the document delimited by a start tag
(such as <name>) and an end tag (such as </name>), or is an empty-element
tag (a standalone tag whose name ends with a forward slash (/), such as
<break/>). Start tags and end tags surround content and possibly other
markup whereas empty-element tags don’t surround anything. Figure 1-1
reveals Listing 1-1’s XML document tree structure.

Figure 1-1. Listing 1-1’s tree structure is rooted in the recipe element

As with the HTML document structure, the structure of an XML document


is anchored in a root element (the topmost element). In HTML, the root
element is html (the <html> and </html> tag pair). Unlike in HTML, you can
choose the root element for your XML documents. Figure 1-1 shows the root
element to be recipe.
Unlike the other elements, which have parent elements, recipe has no
parent. Also, recipe and ingredients have child elements: recipe’s children
are title, ingredients, and instructions; and ingredients’ children are
three instances of ingredient. The title, instructions, and ingredient
elements don’t have child elements.
6 CHAPTER 1: Introducing XML

Elements can contain child elements, content, or mixed content (a


combination of child elements and content). Listing 1-2 reveals that
the movie element contains name and language child elements, and also
reveals that each of these child elements contains content (language
contains français, for example). Listing 1-3 presents another example that
demonstrates mixed content along with child elements and content.

Listing 1-3. An abstract Element Containing Mixed Content

<?xml version="1.0"?>
<article title="The Rebirth of JavaFX" lang="en">
<abstract>
JavaFX 2 marks a significant milestone in the history of JavaFX. Now
that Sun Microsystems has passed the torch to Oracle, we have seen the
demise of JavaFX Script and the emergence of Java APIs (such as <code-
inline>javafx.application.Application</code-inline>) for interacting with
this technology. This article introduces you to this new flavor of JavaFX,
where you learn about JavaFX 2 architecture and key APIs.
</abstract>
<body>
</body>
</article>

This document’s root element is article, which contains abstract and body
child elements. The abstract element mixes content with a code-inline
element, which contains content. In contrast, the body element is empty.

Note As with Listings 1-1 and 1-2, Listing 1-3 also contains whitespace
(invisible characters such as spaces, tabs, carriage returns, and line feeds). The
XML specification permits whitespace to be added to a document. Whitespace
appearing within content (such as spaces between words) is considered part
of the content. In contrast, the parser typically ignores whitespace appearing
between an end tag and the next start tag. Such whitespace isn’t considered
part of the content.

An XML element’s start tag can contain one or more attributes. For example,
Listing 1-1’s <ingredient> tag has a qty (quantity) attribute and Listing 1-3’s
<article> tag has title and lang attributes. Attributes provide additional
details about elements. For example, qty identifies the amount of an
ingredient that can be added, title identifies an article’s title, and lang
identifies the language in which the article is written (en for English).
Attributes can be optional. For example, when qty isn’t specified, a default
value of 1 is assumed.
CHAPTER 1: Introducing XML 7

Note Element and attribute names may contain any alphanumeric character
from English or another language, and may also include the underscore (_),
hyphen (-), period (.), and colon (:) punctuation characters. The colon should
only be used with namespaces (discussed later in this chapter), and names
cannot contain whitespace.

Character References and CDATA Sections


Certain characters cannot appear literally in the content that appears
between a start tag and an end tag or within an attribute value. For example,
you cannot place a literal < character between a start tag and an end tag
because doing so would confuse an XML parser into thinking that it had
encountered another tag.
One solution to this problem is to replace the literal character with a
character reference, which is a code that represents the character. Character
references are classified as numeric character references or character entity
references:
„ A numeric character reference refers to a character
via its Unicode code point and adheres to the format
&#nnnn; (not restricted to four positions) or &#xhhhh;
(not restricted to four positions), where nnnn provides
a decimal representation of the code point and hhhh
provides a hexadecimal representation. For example,
&#0931; and &#x03A3; represent the Greek capital
letter sigma. Although XML mandates that the x in
&#xhhhh; be lowercase, it’s flexible in that the leading
zero is optional in either format and in allowing you to
specify an uppercase or lowercase letter for each h.
As a result, &#931;, &#x3A3;, and &#x03a3; are also valid
representations of the Greek capital letter sigma.
„ A character entity reference refers to a character via
the name of an entity (aliased data) that specifies the
desired character as its replacement text. Character
entity references are predefined by XML and have the
format &name;, in which name is the entity’s name. XML
predefines five character entity references: &lt; (<), &gt;
(>), &amp; (&), &apos; ('), and &quot; (").
Consider <expression>6 < 4</expression>. You could replace the < with
numeric reference &#60;, yielding <expression>6 &#60; 4</expression>,
or better yet with &lt;, yielding <expression>6 &lt; 4</expression>.
The second choice is clearer and easier to remember.
8 CHAPTER 1: Introducing XML

Suppose you want to embed an HTML or XML document within an element.


To make the embedded document acceptable to an XML parser, you would
need to replace each literal < (start of tag) and & (start of entity) character
with its &lt; and &amp; predefined character entity reference, a tedious and
possibly error-prone undertaking—you might forget to replace one of these
characters. To save you from tedium and potential errors, XML provides an
alternative in the form of a CDATA (character data) section.
A CDATA section is a section of literal HTML or XML markup and content
surrounded by the <![CDATA[ prefix and the ]]> suffix. You don’t need to
specify predefined character entity references within a CDATA section, as
demonstrated in Listing 1-4.

Listing 1-4. Embedding an XML Document in Another Document’s CDATA Section

<?xml version="1.0"?>
<svg-examples>
<example>
The following Scalable Vector Graphics document describes a blue-
filled and black-stroked rectangle.
<![CDATA[<svg width="100%" height="100%" version="1.1"
xmlns="http://www.w3.org/2000/svg">
<rect width="300" height="100"
style="fill:rgb(0,0,255);stroke-width:1; stroke:rgb(0,0,0)"/>
</svg>]]>
</example>
</svg-examples>

Listing 1-4 embeds a Scalable Vector Graphics (SVG; [see


https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) XML
document within the example element of an SVG examples document.
The SVG document is placed in a CDATA section, obviating the need to
replace all < characters with &lt; predefined character entity references.

Namespaces
It’s common to create XML documents that combine features from different
XML languages. Namespaces are used to prevent name conflicts when
elements and other XML language features appear. Without namespaces, an
XML parser couldn’t distinguish between same-named elements or other
language features that mean different things, such as two same-named
title elements from two different languages.
Random documents with unrelated
content Scribd suggests to you:
Crowns
1. Crown of England. 2. Russian Crown. 3.
French Crown. 4. Austrian Crown. 5. Imperial
Crown (Charlemagne’s).

In modern states they were also of various forms until heralds


devised a regular series to mark the grades of rank from the imperial
crown to the baron’s coronet.
The English crown has been gradually built up from the plain circlet
with four trefoil heads worn by William the Conqueror. This form was
elaborated and jeweled, and finally arched in with jeweled bands
surmounted by the cross and scepter. As at present existing, the
crown of England is a gold circle, adorned with pearls and precious
stones, having alternately four Maltese crosses and four fleur-de-lis.
From the top of the crosses rise imperial arches, closing under a
mound and cross. The whole covers a crimson velvet cap with an
ermine border.
The crown of Charlemagne, which is preserved in the imperial
treasury of Vienna, is composed of eight plates of gold, four large
and four small, connected by hinges. The large plates are studded
with precious stones, the front one being surmounted with a cross;
the smaller ones, placed alternately with these, are ornamented with
enamels representing Solomon, David, Hezekiah and Isaiah, and
Christ seated between two flaming seraphim.
The Austrian crown is a sort of cleft tiara, having in the middle a
semicircle of gold supporting a mound and cross; the tiara rests on a
circle with pendants like those of a miter.
The royal crown of France is a circle ornamented with eight fleur-de-
lis, from which rise as many quarter-circles closing under a double
fleur-de-lis. The triple crown of the popes is more commonly called
the tiara.

Why do Lobsters Change Colors?


Before a lobster is cooked he is green, that being the color of the
rocks around which he lives on the bottom of the ocean. However, as
soon as a lobster is placed in boiling water his shell changes from
green to red. This is due to a certain chemical substance contained in
the shell which acts in that way when boiled.

How do Fishes Swim?


The fish is entirely surrounded by water which exerts an equal
pressure on all sides. When the fish moves its tail, or makes any
movement at all, he moves in the water. Of course, by moving his tail
from side to side he propels himself forward and by bending his tail
he goes in the direction in which it is bent.

Where do Pearls Come From?[31]


Below the surface of the ocean, there’s a strange, enchanted world.
Living in the midst of its grandeur are most marvelous and delicate
creatures that ceaselessly toil to strew the ocean’s bed with lustrous
gems—pearls.
Nature provides for the denizens of the deep that make these
beautiful gems. The ocean pearl oyster or bivalve (avicula
margaritifera) and fresh water mussel (unio margaritifera) have
wonderful homes—their shells. Coarse, rough, rugged, often distorted
on the outside, within they are lined with smooth, softly-glowing,
iridescent “mother of pearl.” The membrane, attaching the bivalve to
its shell, extracts lime from the water, building the shell from the
inside outward in successive layers, preserving the finest nacreous
secretions for the smooth inside lining, thus protecting its delicate
body.
In this comfortable home the mollusk is contented, but an enemy
sometimes attacks it by boring through its hard shell. Leucodore,
clione and other borers, parasitic or domiciliary worms work into the
shell, and instinctively the protecting nacreous fluid envelops the
intruder. This is the birth of the pearl. The intruder, now covered
entirely with the pearl-nacre, is constantly rolled and lapped about,
and successive layers of nacre are applied until in a few years a pearl
of great size and value is formed and awaits the hardy, daring pearl
fisher.
Pearls were the first gems discovered and used as ornaments in
prehistoric ages. Found in their natural state in utmost perfection,
needing no cutting nor polishing, these glowing beads of the sea
were the first baubles of savages, tribes and nations. Today the pearl
is the favored gem of those who are surfeited with valuable jewels. It
is essentially a gem for the wealthy. The connoisseur, accustomed to
the possession of jewels, finds in its soft luster a grandeur above that
of all the sparkling stones.
Fancy pearls include all those of decided color, having a rare and
beautiful tint. “White pearls” include pure white and white slightly
tinted with pink, blue, green or yellow. Of these colored white pearls,
the delicate, lightly-tinted, pink pearl of fine color and luster known
as “rose” is most beautiful. Every white pearl is classified according to
its respective tint and thus its price is determined, the values ranging
in the order named above, from highest for pure white, to lowest for
yellowish-white.
What is Cork?
Cork is the outer bark of a species of oak which grows in Spain,
Portugal and other southern parts of Europe and in the north of
Africa. The tree is distinguished by the great thickness and
sponginess of its bark, and by the leaves being evergreen, oblong,
somewhat oval, downy underneath, and waved.
The outer bark falls off of itself if let alone, but for commercial
purposes it is stripped off when judged sufficiently matured, this
being when the tree has reached the age of from fifteen to thirty
years. In the course of eight or nine years, or even less, the same
tree will yield another supply of cork of better quality, and the
removal of this outer bark is said to be beneficial, the trees thus
stripped reaching the age of 150 years or more.
The bark is removed by a kind of ax, parallel cuts being carried
around the tree transversely and united by others in a longitudinal
direction, so as to produce oblong sheets of bark. Care must be taken
not to cut into the inner bark, or the tree would be killed. The pieces
of cork are flattened out by heat or by weights, and are slightly
charred on the surface to close the pores.
Cork is light, impervious to water, and by pressure can be greatly
reduced in bulk, returning again to its original size. These qualities
render it peculiarly serviceable for the stopping of vessels of different
kinds, for floats, buoys, swimming-belts or jackets, artificial limbs,
etc. Corks for bottles are cut either by hand or by means of a
machine. The best corks are cut across the grain.
The Story in a Giant Cannon

Origin of the Cannon.


The shotgun and rifle, the familiar weapons of the sportsman and the
foot-soldier, are not the ancestors of the cannon, as might be
surmised. On the contrary, the cannon was the predecessor of the
musket and its successors. The rifle, however, antedated the rifled
cannon, the type of modern artillery. We do not know when cannon
first appeared, but it may have been soon after the discovery of
gunpowder in Europe. This explosive seems to have been known in
China long before knowledge of it reached the west, but we do not
know to what extent it was developed and used in that country.

Three-inch Field Gun Under Test at Fort Riley, Kansas


In the trials conducted by the Board of Ordnance and
Fortification of the United States Army. This gun and
carriage, complete, weighs 2,020 pounds. Charge, 18.5
ounces of smokeless powder. Weight of projectile, 15
pounds. Muzzle velocity, 1,800-foot seconds.
Courtesy of the Bethlehem Steel Co.

The earliest cannon of which we have any knowledge were clumsy


contrivances, at first wider at the mouth than at the chamber, and
made of wood, and later of iron bars, hooped together with iron
rings, a system of the same type as that now in use in the wire-
wound cannon. They at first seem to have fired balls of stone, iron
balls coming later. A doubtful statement exists to the effect that
cannon were used at the siege of Belgrade in 1073, and it is said that
Edward III used them against the Scotch in 1327. Other dates of their
use are 1338 and 1346, in which latter year Edward III employed
them against the French at Crecy. For this we have the authority of
Froissart. They were known under the varied names of bombards,
serpentines, etc. Twelve cannon cast by Louis VII were named after
the twelve peers of France, and Charles V gave twelve others the
names of the twelve apostles. Other titles came later into general
use, the royal or carthorne, carrying 48 pounds; the culverin, 18
pounds; the demi-culverin, 9 pounds; the basilisk, 48; the siren, 60,
etc. In still later times cannon became known by the weight and the
balls they carried, 6-pounders, 12-pounders, etc. But they are now
usually called after the size of their bores, as 6-inch, 8-inch, or 12-
inch cannon. The oldest example still in existence is “Mons Meg,”
preserved at Edinburgh Castle. This is one of the iron-bar type,
hooped by iron rings. It is supposed to have been used by James II
of Scotland, at the siege of Threave Castle in 1455.
Three Inch Naval Landing Gun, Carriage and Limber
Weight of gun and mechanism, 675 pounds. Length of gun,
74.35 inches (25 calibers). Weight of projectile, 13 pounds.
Travel of projectile in bore, 62.9 inches (20.97 calibers).
Weight of charge, 18 ounces of smokeless powder. Muzzle
velocity, 1,650-foot seconds. Muzzle energy, 246-foot tons.
Weight of gun, carriage, limber, drag ropes, tools, etc., and
60 rounds of ammunition, complete, 3,420 pounds. The
carriage and limber have each two removable
interchangeable ammunition boxes for 12 rounds each, with
a box for 12 rounds below the axle of the limber.
Courtesy of the Bethlehem Steel Co.

Louis VI used bombards of great length and power against the


Flemish in 1477, while as early as 1401 bronze cannon had been cast
in several cities of West Prussia. Iron cannon were not cast until near
the end of that century. Coming down to the seventeenth century, we
are told of the great Bijapur cast-iron gun, the “Lord of the Plain,”
cast by the Mogul emperor Auremgzebe or by his foes the Mahrattas.
This huge gun was 14 feet long, 28 inches bore, and fired a ball of
1,600 pounds weight. Smooth-bore cannon and mortars of cast-iron
and bronze are still retained in some fortresses, though rifled cannon
are the only type now made. As late as 1864 smooth-bore 100- and
150-pounder wrought-iron guns were made for the British navy and a
few bronze rifled guns were made in 1870 for service in India, but all
such guns are now obsolete.
[388]

Twenty-eight Ton Austrian Siege Howitzer Which Fires a Thousand-pound Projectile


The Germans borrowed a large number of these great siege pieces from the
Austrians and used them in the reduction of the Belgian defenses. Huge shells
filled with high explosives from these mammoth guns rapidly destroyed the most
modern and powerful fortifications known at the beginning of the great war. It is
known that against such weapons of offense no fortifications can last and that
the employment of such weapons has forced both armies to depend on their
trenches as their main defense.

[389]
Conquering the Alps.
Immense labor and great ingenuity were required to haul the monster Italian guns
up the steep mountain sides to their positions.

[390]
The Most Formidable of the French Army’s Trench Artillery
80-m.m. mountain gun loaded with air-mine weighing 130 pounds. These mines
can be thrown for a considerable distance and create havoc in the enemy’s
trenches if the aim is true.

[391]
The Bennett-Mercier Machine Gun
This new automatic machine gun has been adopted by the United States Army,
Navy and Marine Corps. It is handled by two men, one to aim and fire it, the other
to feed the cartridges which are held in brass clips of 30 each. The complete gun
weighs only about 35 pounds, fires 400 shots per minute, using regular 30-caliber
Springfield rifle cartridges, with a maximum range of 3 miles and an effective
range of about 2,000 yards. The weapon is air cooled and can be fired steadily for
about 10 minutes without undue heating.

[392]
Three-inch Field Gun, Long Recoil Carriage and Limber
Weight of gun, carriage and limber complete, including 36
rounds of ammunition, 4,200 pounds; ground clearance,
22.5 inches. Seats are provided on axle of carriage for two
gunners in transportation, one of whom operates the road
brake.
Courtesy of the Bethlehem Steel Co.

The development of the rifle from the old smooth-bore musket, by


cutting grooves or channels in the form of a screw in the interior
surface, was found so advantageous in increase of precision of aim
and length of range, that the rifling of cannon in time followed and is
now universally used. Breech loading has also replaced muzzle
loading, another vast advantage in the use of artillery. A form of
breech-loading cannon was introduced in the sixteenth century, but
the advantageous use of this device is of late invention. An important
result of these changes is the use of elongated instead of round balls,
this permitting of the employment of much heavier projectiles for the
same width of bore.
Modern Cannon.
Until 1888 the largest cannon in use was the 119-ton Krupp, made in
1884 for Italy; but in 1888-90 the same house produced a 135-ton
gun for Cronstadt. The heaviest British gun at that time was of 111-
ton weight. This threw a projectile of 1,800 pounds with a muzzle
velocity of 2,216 feet per second. But there later came a reaction in
favor of lighter guns and quick firers. The heavy cannon of recent
times are not cast, as of old, but are made of forged-steel by what is
known as the building-up process. The different parts of these are
called the tube, jacket, hoops, locking rings, trunnion rings, wire
winding, etc.
Cannons are subject to great stress in firing, this being of two kinds.
One is the longitudinal stress, acting in the direction of the length and
tending to pull the muzzle away from the breech. The other is the
circumferential or tangential stress, which tends to split the gun open
in lines parallel to the axis of the bore. These stresses are results of
the longitudinal and radial pressures of the gas developed by the
ignition and explosion of the powder. Such destructive forces have to
be guarded against in the building of a cannon and have led to a
great development over the old-time casting processes. As long as
projectile velocities under 1,500 feet per second were employed
cannons cast in one piece sufficed, but when greater velocities were
sought, the pressure grew so extreme that no cast or forged metal
tube would stand the strain.
Three-inch Mountain Gun and Carriage
Weight of gun, 2061⁄2 pounds. Length of gun, 37.25 inches (12.4
calibers). Weight of projectile, 12 pounds. Travel of projectile in
bore, 27.55 inches (9.2 calibers). Weight of charge, 12.5 ounces of
smokeless powder. Muzzle velocity, 1,224-foot seconds. Muzzle
energy, 123-foot tons. Weight of gun and carriage complete, 726
pounds. This gun and carriage break up into four loads of
approximately 200 pounds each. The equipment carries 16
complete rounds of ammunition with it, which are divided equally
among four boxes. The saddles are so made that the load will go
on any saddle.
Courtesy of the Bethlehem Steel Co.

How Cannon are Now Made.


It was found that the inner surface of the tube stretched more than
the outer surface, and that after the inner surface had been stretched
to its limit of elasticity the outer part failed to add to its strength, so
that further thickness was of no benefit. To do away with this
condition cannon were constructed on the principle of varying
elasticity, the metal with the greatest elongation within its elastic limit
being placed next to the bore, yet in high-powered guns this system
failed to yield the result desired and it was replaced by what is known
as the initial tension system. This comprised two methods: the plain
built-up gun and the wire-wound gun. In the latter certain parts of
the gun were wrapped with wire in the form of a ribbon.

Rapid-Fire Gun
Six-inch rapid-fire gun equipped with patented two-handed
elevating gear, consisting of two hand wheels on opposite
ends of the same shaft, the handles being 180 degrees
apart. The pointer uses both hands in elevating and
depressing the gun. The electric firing trigger A is worked by
the index finger of the right hand without releasing the
handle. There is a second firing handle B attached to the
slide, for firing either electrically or percussively.
Courtesy of the Bethlehem Steel Co.

Built-Up and Wire-Wound Guns.


A built-up gun is made of several layers of forged steel. The parts of
such a gun are known as the liner, the tube, the jacket and the
hoops. The liner is a single piece which extends the length of the
bore and is intended to contain the rifling and the powder chamber.
This is inclosed by the tube, which is also in one piece, surrounding
the liner throughout its length. Outside this is the jacket, made in two
pieces and shrunk on the tube. Over the jacket lie the hoops, six or
seven of these being used in a big gun. Like the jacket, these also are
shrunk on. All these parts are made of the finest quality of open-
hearth steel.
[395]

Five-Inch Naval Gun and Mount


The latest type of gun used in the U. S. Naval Service in the secondary batteries
on a battleship.

[396]
Coast Defense Gun
A modern 14-inch coast defense gun at Sandy Hook. The gun is mounted on a
disappearing carriage, which lowers it out of sight behind the breastworks after
firing. This is one of the most powerful guns in the world, firing a projectile which
would pierce the armor of a battleship more than five miles away.

[397]
Copyright by Underwood & Underwood, N. Y.
A Battery of 12-inch Coast Defense Mortars
These powerful weapons fire a projectile which weighs from 700 to 1,046 pounds,
depending on the range desired, and which is capable of piercing the deck armor
of any battleship. They have a range of 20,000 yards with the 700-pound
projectile. The gun is 162⁄3 feet long and is fired only at elevations between 45°
and 65°.

[398]
Large image (1143 x 1499 px, 703 kB).
Giant Guns—Their Muzzle-Energy, Projectiles, and Penetrating
Powers
The British 13.5, which was known as the 12-inch-A until the
“Lion” was launched, has a length of 45 calibers, and a muzzle-
energy ten per cent greater than that of the 50-caliber 12-inch
of 1909 and 1910. It may be noted that the caliber is the
diameter of the bore of a gun. The statement that a gun has a
length of 45 calibers, for example, implies that the gun is forty-
five times the bore’s diameter. Thus a 12-inch gun of 45
calibers is 45 feet long.

These pieces are prepared with the utmost care to prevent any
defective material entering into the make-up of the gun. After the
parts are put together a thorough forging follows, either by use of
hammer or press, the latter being now used in preference. The usual
practice in forging is to continue it until the ingot is decreased to one-
half its original thickness and is within two inches of the desired
diameter of the finished work. It is then annealed with great care to
relieve the strains set up in the metal by the forging and next goes to
the machine shop to be rough bored and turned. The final boring
takes place after a second annealing. The above is only a rapid
sketch of the total process, in which elaborate care is taken to
prevent imperfection of any kind.

Ordnance Proving Ground


View showing smoke cone occurring during the proof firing
of a twelve-inch gun with brown powder.
Courtesy of the Bethlehem Steel Co.

In a wire-wound gun an inner tube of steel is thoroughly wrapped by


successive layers of ribbon wire, each layer being wound with wire at
a different tension. This type of gun is preferred by foreign
manufacturers, but within the United States the built-up system is in
higher favor and is almost exclusively employed. The makers of the
wire-wound cannon claim for it a positive soundness of material
impossible to secure in a built-up gun, and that it has greater
firmness of material and superior tangential strength. But with this
come certain disadvantages, a notable one being a lack of rigidity in
the longitudinal direction, this tending to increase the “droop” of the
muzzle and give a certain “whip” to the piece when fired that reduces
accuracy. This and other disadvantages have given the built-up guns
general preference in this country, they being found strong enough to
bear any pressure desirable in service. In addition they are much
cheaper to build than the wire-wound guns.
Modern heavy guns are made of medium open-hearth carbon steel,
forged as stated. The liner and tube are then placed upright in an
assembling pit, the jacket and hoops shrunk on, and the finishing
work done, as above said, the breech mechanism being finally fitted.
Within recent years there has been a steady increase in the size and
range of cannon, until an immense size and weight have been
attained. For naval purposes the 14-inch gun is the largest now used
in American battleships, but in the United States coast defense forts,
16-inch guns are installed. England has equipped several of her latest
battleships with 15-inch guns and other nations are following in the
same direction. In recent great battleships four turrets are used, each
carrying three of these great guns, giving a broadside of twelve of
these monster weapons of war. Of the three guns, the middle one is
raised above the line of the others. A battleship thus armed is able to
fire six guns ahead and six astern by raising the second and third
turrets so as to fire over the others.
Four-inch Fifty Caliber Rapid-Fire Gun on Pedestal Mount
Extraction of cartridge case by opening of breech
mechanism. Weight of gun, 6,170 pounds. Length of gun,
205 inches (51.2 calibers). Weight of projectile, 33 pounds.
Travel of projectile in bore, 165.6 inches (41.4 calibers).
Weight of charge, 15 pounds of smokeless powder. Muzzle
velocity, 2,900-foot seconds. Muzzle energy, 1,928-foot tons.
Weight of mount with shield, 9,470 pounds. Thickness of
shield, 2 inches of nickel steel. Gun equipped with telescopic
and night sights and with electric and percussion pull-off
firing gear.
Courtesy of the Bethlehem Steel Co.

Military cannon are divided into three classes, based upon the length
of caliber, and technically known as guns, mortars and howitzers. In
guns the length is relatively great, in mortars relatively small,
compared to their calibers. Howitzers form a class between guns and
mortars in length. The field guns of the American army are the 3.6-
inch breech-loading mortars, and the 3.6-inch heavy and 3.2-inch
light guns. The siege guns in the service are the 5-inch siege guns,
the 7-inch howitzer, and the 7-inch mortar. The coast defense artillery
consists of the 8-, 10-, 12- and 16-inch guns and the 12-inch
mortars. In the recent European war very heavy cannon were used
for field service, pieces of the size usually placed in forts being drawn
to the field by powerful tractors, set on concrete platforms and used
in attacks on fortified cities. It was through the use of such ordnance
that the German army so easily reduced the strongly fortified Belgian
cities.

Fluid Compression Plant


While still in a molten condition in the mold, the steel
used in manufacturing guns and shafting is subjected
to hydraulic pressure until the ingot has cooled, thus
insuring the solidity of the metal. The upper head of
the compressor weighs 125 tons, and the lower one,
including the cylinder through which the hydraulic
pressure is applied, 135 tons.
Courtesy of the Bethlehem Steel Co.

[402]

Ammunition.[32] (See page 410.)

Two-Handed Elevating Gear.[32] (See page 410.)


[403]

Range Finder and Predictor; Home and Distant Station


Instruments.[33] (See page 410.)

Armor Piercing Projectiles, Capped and Uncapped.[33] (See page


410.)

[404]
Range Finder and Chart Attachment[34]. (See page 410.)

Eighteen-inch, Thirty-caliber Torpedo Gun.[34] (See page 410.)

[405]
Firing Gear for Guns.[35] (See page 410.)

Fuses.[35] (See page 410.)

The range of these giant cannon is enormous and their destructive


power great, this being added to by the fact that the explosive shell
has replaced the solid round shot of old-time gunnery. A 14-inch gun
of 45 caliber can discharge a 1,400-pound projectile at a muzzle
velocity of 2,600 feet per second. If we compare this with a
locomotive going at the speed of sixty miles an hour, we have in the
latter a speed of eighty-eight feet per second to compare with the
2,600 feet per second of the cannon ball. From this we can well
conjecture the vast speed with which the latter moves, its enormous
range and vast powers of destruction.

Three-inch Horse Artillery Gun, Long Recoil Carriage and Limber


Length of gun, 85 inches (28 calibers). Weight of projectile,
12 pounds. Travel of projectile in bore, 74.65 inches (24.88
calibers). Weight of charge, 17.1 ounces of smokeless
powder. Muzzle velocity, 1,750-foot seconds. Muzzle energy,
255-foot tons. Weight of gun, carriage and limber, containing
36 rounds of ammunition, 3,355 pounds. Ground clearance,
18 inches.
Courtesy of the Bethlehem Steel Co.

As facts are better than theories, it will be of interest to adduce a


recent example of gunnery of a most illuminating type, but as regards
distance and remarkable accuracy of aim. In September, 1916, the
American battleship “Pennsylvania,” armed with a main battery of
twelve 14-inch guns, fired these simultaneously at a target in the
Chesapeake 22,000 yards, or more than twelve miles, away. The
target was the sunken hulk of the “San Marcos,” formerly the
battleship “Texas,” which for several years had been used for similar
purposes. As the target was invisible to the gunners it was hardly to
be expected that any of the shots should fall near the target. But the
extraordinary result appeared that five of these twelve shots struck
the hulk. As each of these projectiles weighed 1,400 pounds any
battleship receiving such a broadside would probably have gone
promptly to the bottom. The result, which has never before been
equaled in accuracy, sufficiently attests the remarkable proficiency in
range-finding that modern engineers have developed.
As for the penetrating powers of such huge shot we may take the 15-
inch gun, the type of the largest guns in our fortifications and which
is claimed to be able to pierce sixteen inches of armor at a range of
18,000 yards and ten inches at a range of 20,000 yards. A notable
example of this took place on September 15, 1916, at the proving
grounds at Indian Head, on the Potomac River, when a 16-inch,
2,100-pound, solid steel shell, said to be the first ever fired from a
naval gun of that caliber, with a small charge of explosive, went
through a plate of armor, penetrated a thick sand backing, and
continued its course, striking the house of an employee of the
proving grounds and plunging through the kitchen rending all before
it. This was a naval gun, the largest yet made for naval purposes.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like