public class CustomXmlSchemaCollection
You do not create instances of this class. You access the collection of XML schemas of a custom XML part
via the
Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
Property Getters/Setters Summary | ||
---|---|---|
int | getCount() | |
Gets the number of elements contained in the collection.
|
||
java.lang.String | get(int index) | |
void | set(intindex, java.lang.Stringvalue) | |
Gets or sets the element at the specified index. |
Method Summary | ||
---|---|---|
void | add(java.lang.String value) | |
Adds an item to the collection.
|
||
void | clear() | |
Removes all elements from the collection.
|
||
CustomXmlSchemaCollection | deepClone() | |
Makes a deep clone of this object.
|
||
int | indexOf(java.lang.String value) | |
Returns the zero-based index of the specified value in the collection.
|
||
java.util.Iterator<java.lang.String> | iterator() | |
Returns an iterator object that can be used to iterate over all items in the collection.
|
||
void | remove(java.lang.String name) | |
Removes the specified value from the collection.
|
||
void | removeAt(int index) | |
Removes a value at the specified index.
|
public int getCount()
Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public java.lang.String get(int index) / public void set(int index, java.lang.String value)
Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public void add(java.lang.String value)
value
- The item to add.Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public void clear()
Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public CustomXmlSchemaCollection deepClone()
Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public int indexOf(java.lang.String value)
value
- The case-sensitive value to locate.Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public java.util.Iterator<java.lang.String> iterator()
Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public void remove(java.lang.String name)
name
- The case-sensitive value to remove.Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);
public void removeAt(int index)
index
- The zero based index.Example:
Shows how to work with an XML schema collection.// Create a document and add a custom XML part Document doc = new Document(); String xmlPartId = UUID.randomUUID().toString(); String xmlPartContent = "<root><text>Hello, World!</text></root>"; CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent); // Once the part is created, we can add XML schema associations like this, // and perform other collection-related operations on the list of schemas for this part xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema"); // Collections can be cloned and elements can be added CustomXmlSchemaCollection schemas = xmlPart.getSchemas().deepClone(); schemas.add("http://www.w3.org/2001/XMLSchema-instance"); schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType"); Assert.assertEquals(schemas.getCount(), 3); Assert.assertEquals(schemas.indexOf(("http://schemas.microsoft.com/office/2006/metadata/contentType")), 2); // We can iterate over the collection with an enumerator Iterator<String> enumerator = schemas.iterator(); while (enumerator.hasNext()) { System.out.println(enumerator.next()); } // We can also remove elements by index, element, or we can clear the entire collection schemas.removeAt(2); schemas.remove("http://www.w3.org/2001/XMLSchema"); schemas.clear(); Assert.assertEquals(schemas.getCount(), 0);