You can use XItemFactory to create new items and sequences of items of different types.
An item itself can be a node or an atomic value such as an integer, string, or boolean.
// Create an XFactory XFactory factory = XFactory.newInstance(); // Create an XItemFactory XItemFactory itemFactory = factory.getItemFactory(); // Create a new atomic item of a type which is the default mapping of the xs:string built-in type to java.lang.String XItemView stringItem = itemFactory.item("Lets see"); // Create a new atomic item of type int XItemView intItem = itemFactory.item(3, XTypeConstants.INT_QNAME); // Create a new atomic item of type boolean boolean boolValue = false; XItemView booleanItem = itemFactory.item(boolValue, XTypeConstants.BOOLEAN_QNAME); // Create Node type DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); // Parse the input file Document doc = db.parse(INPUT_File); Node node = doc.getFirstChild(); XItemView item =itemFactory.item(node) // Create a new item of complex type from a Source StreamSource source = new StreamSource(INPUT_File); XItemView complexItem = itemFactory.item(source);
As shown in the example, you can use item method with one argument as the value of the method and the type is evaluated based on the mapping rules between built-in types and Java types.
// Create an XFactory XFactory factory = XFactory.newInstance(); // Create an XItemXFactory XItemFactory itemFactory =xfactory.getItemFactory(); //Create a sequence of int values XSequenceCursor intSeq = xfactory.sequence(new int[]{1,2,3}); //Create a sequence of String values XSequenceCursor stringSeq = xfactory.sequence(new String[]{"This", "is", "a", "test"},XTypeConstants.STRING_QNAME );
// Create an XFactory XFactory factory = XFactory.newInstance(); // Create an XItemXFactory XItemFactory itemFactory = factory.getItemFactory(); //Create an Array of the newly created items XItemView[] items = new XItemView[2]; items[0] =itemFactory.item(boolValue, XTypeConstants.BOOLEAN_QNAME); items[1] = itemFactory.item(intValue, XTypeConstants.INT_QNAME); // Create a sequence of items XSequenceCursor seq = itemFactory.sequence(items);
In this information ... | IBM Redbooks, demos, education, and more(Index) Use IBM Suggests to retrieve related content from ibm.com and beyond, identified for your convenience. This feature requires Internet access. Most of the following links will take you to information that is not part of the formal product documentation and is provided "as is." Some of these links go to non-IBM Web sites and are provided for your convenience only and do not in any manner serve as an endorsement by IBM of those Web sites, the material thereon, or the owner thereof. |