Displaying keyword search results 1 - 6
Created by Dr. Xi on April 29, 2013 09:00:48 Last update: April 29, 2013 09:00:48
In the case proposed by Diony , signing multiple elements by id, simply change the newSignedInfo to:
// Create the SignedInfo final List transforms0...I must admit that I don't understand transformations, so take my example code with a grain of salt. Also, signing a doc fragment by PATH does not work, simply because there's no way to identify the fragment with a URI without referring to it by id. Reference ode from org.jcp.xml.dsig.internal.dom.DOMURIDereferencer :
// Check if same-document URI and register...
Created by freyo on April 15, 2011 09:00:54 Last update: April 15, 2011 09:00:54
Sample code for writing to a file in the internal storage. There are three steps: Open the file with Context.openFileOutput , which returns java.io.FileOutputStream . Write to the file. Close the file.
import java.io.*; import android.content.Contex...The second parameter to openFileOutput is the operating mode. Available values are: Context.MODE_PRIVATE Context.MODE_APPEND Context.MODE_WORLD_READABLE Context.MODE_WORLD_WRITEABLE The file is saved in /data/data/<package_name>/files .
Created by Fang on August 23, 2010 22:55:58 Last update: August 24, 2010 15:45:04
The tags XML flow control tags are exactly the same as their Core flow control equivalents, except that the test condition with a boolean EL expression is replaced by the select condition with an XPath expression. In the case of the forEach tag, the items attribute is replaced with the select attribute. In a test condition, the XPath expression is evaluated to a boolean value by the rules of the XPath boolean() function, which converts its argument to a boolean as follows: a number is true if and only if it is neither positive or negative zero nor NaN. a node-set is true if and only if it is non-empty. a string is true if and only if its length is non-zero. an object of...
Created by Dr. Xi on July 19, 2010 21:58:34 Last update: July 23, 2010 21:37:23
Parsing XML in Java is really simple:
import java.io.*; import javax.xml.parsers.Docu...The parser implementation details are hidden behind the JAXP API. In case you want to know which parser implementation is used, this is what the JavaDoc for DocumentBuilderFactory.newInstance says: Use the javax.xml.parsers.DocumentBuilderFactory system property. Use the properties file " lib/jaxp.properties " in the JRE directory. This configuration file is in standard java.util.Properties format and contains the fully qualified name of the implementation class with the key being the system property defined above. The jaxp.properties file is read only once by the JAXP implementation and it's values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to...
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 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 java.io.*; 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...