Recent Notes

Displaying keyword search results 1 - 4
Created by Dr. Xi on July 21, 2010 22:14:53    Last update: July 21, 2010 22:14:53
This is a Java program to test XPATH expressions with namespace option. It's been tested with JDK1.6. import; import java.uti... Following Getting Started with XML Security , these are the test files: Without namespace (patient.xml). <PatientRecord> <Name>John Doe</Nam... With namespace (patient_ns.xml). <med:PatientRecord xmlns:med="http://www.medic... Test results: C:\>java XPathExample patient.xml /PatientRecord/V...
Created by Dr. Xi on June 20, 2010 14:35:17    Last update: June 20, 2010 14:35:17
This XML signature validator comes from the Apache XML Security project. It validates the signature according to the core validation processing rules . It does not verify that the key used to generate the signature is a trusted key. You can override the KeySelector class to make sure that the signing key is from a trusted store. import javax.xml.crypto.*; import javax.xml.cry...
Created by Dr. Xi on June 19, 2010 04:34:01    Last update: June 19, 2010 04:39:13
Java SE 6 contains built-in utilities to generate XML signatures. This is an example that generates XML signatures using a Java keystore. It has options to generate signature for the whole document, for an element with a specific ID, or for elements matched by an XPATH expression. The XML document used to test is taken from Getting Started with XML Security : <?xml version="1.0"?> <PatientRecord> ... This is the Java code: import; import However, it looks like the XPATH transform is not working. The digest generated with XPATH filter is exactly the same as that without it (i.e., the whole document)! Another reference: Programming With the Java XML Digital Signature API
Created by Dr. Xi on June 11, 2010 23:11:59    Last update: June 11, 2010 23:14:02
Given a simple XML file like this: <?xml version="1.0"?> <root id="1"> ... Calling Document.getElementById returns null (surprisingly!): import*; import org.w3c.dom.*; impo... In fact the JavaDoc says something along the lines that getElementById returns the Element that has an ID attribute with the given value. An attribute with the name "ID" or "id" is not of type ID unless it is so defined. How is an attribute defined as an ID attribute ? With a DTD or schema. If you are not validating the XML, then the API is useless. So, what to do if you want to find an element for which the attribute named "id" has a given value? Several options were offered in GetElementById Pitfalls . One of them is to...