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);