Java Reference
In-Depth Information
xp.evaluate("author", books.item(0),
XPathCon-
stants.NODESET);
List<Author> auths = new ArrayList<>();
for (int i = 0; i < authors.getLength(); i++)
auths.add(new
Author(authors.item(i).getFirstChild()
.getNodeValue().trim()));
Book book = new Book(isbn, title, publisher, pub-
Year, auths);
library.put(isbn, book);
serialize();
}
catch (IOException | TransformerException e)
{
throw new HTTPException(500);
}
catch (XPathExpressionException xpee)
{
throw new HTTPException(400);
}
StringBuilder xml = new StringBuilder("<?xml ver-
sion=\"1.0\"?>");
xml.append("<response>book inserted</response>");
return
new
StreamSource(new
StringRead-
er(xml.toString()));
}
private Source doPut(MessageContext msgContext, Source
source)
{
try
{
DOMResult dom = new DOMResult();
Transformer
t
=
TransformerFact-
ory.newInstance().newTransformer();
t.transform(source, dom);
Search WWH ::




Custom Search