Programming:
XPath:
Prepare your environment in the same way as one week ago (Eclipse, JBoss).
The updated workspace is here XML08-WS.zip. You can also simply add the projects REST directly from the zip to your old workspace.
If the REST project does not compile, you have to add your server runtime to the build path. One of possible solutions is to set "Targeted Runtimes" in the project settings.
Start the JBoss server and run the project REST (e.g. Servers / Add and Remove). Test for example hello?who=Me.
Go to class Kalkulator
and test it using a web browser. Then add more arithmetic operations accessible in the same way as addition.
Go to class XPathService
, test it (using web browser).
Add new parameter xpath
and make the method return the result of the given expression
(it should evaluate to a single node). If the parameter is not given (or empty), return the whole document, as it is now.
All right, there are some technical issues. If you don't know how to manage them, here is an example solution, or here a simpler one, returning a String.
Test the service. Note that slash signs /
must be replaced with %2F
in URLs.
If there is some time left, we can start writing XPath expressions.
Go to XPath
project in the Eclipse workspace and change the perspective to XML
.
You should see the "XPath" window in the bottom-left corner.
Open the file staff.xml and type as "XPath expression" //department[2]
.
Write some XPath queries for the staff.xml example. Select (if possible):
person
) from the second department.count
is the appropriate function).Dodatkowe zadanko po polsku na sztucznym przykładzie. Za pomocą XPath wybierz określone elementy dokumentu przyklad.xml (lub wyraź określone konstrukcje nawet jeżeli takich elementów nie ma :)).
E4
,wyr
,