public class CustomXmlSchemaCollection
extends java.lang.Object
implements java.lang.Iterable
To learn more, visit the Structured Document Tags or Content Control documentation article.
Remarks:
You do not create instances of this class. You access the collection of XML schemas of a custom XML part via the CustomXmlPart.getSchemas() property.
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
CustomXmlPart,
CustomXmlPart.getSchemas()| Modifier and Type | Method and Description |
|---|---|
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.
|
java.lang.String |
get(int index)
Gets the element at the specified index.
|
int |
getCount()
Gets the number of elements contained in the collection.
|
int |
indexOf(java.lang.String value)
Returns the zero-based index of the specified value in the collection.
|
java.util.Iterator |
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.
|
void |
set(int index,
java.lang.String value)
Sets the element at the specified index.
|
public int getCount()
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
public java.lang.String get(int index)
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
public void set(int index,
java.lang.String value)
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
value - The element at the specified index.public java.util.Iterator iterator()
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
iterator in interface java.lang.Iterablepublic void add(java.lang.String value)
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
value - The item to add.public int indexOf(java.lang.String value)
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
value - The case-sensitive value to locate.public void remove(java.lang.String name)
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
name - The case-sensitive value to remove.public void removeAt(int index)
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
index - The zero based index.public void clear()
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);
public CustomXmlSchemaCollection deepClone()
Examples:
Shows how to work with an XML schema collection.
Document doc = new Document();
String xmlPartId = UUID.randomUUID().toString();
String xmlPartContent = "<root><text>Hello, World!</text></root>";
CustomXmlPart xmlPart = doc.getCustomXmlParts().add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.getSchemas().add("http://www.w3.org/2001/XMLSchema");
// Clone the custom XML part's XML schema association collection,
// and then add a couple of new schemas to the clone.
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(3, schemas.getCount());
Assert.assertEquals(2, schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType"));
// Enumerate the schemas and print each element.
Iterator<String> enumerator = schemas.iterator();
while (enumerator.hasNext()) {
System.out.println(enumerator.next());
}
// Below are three ways of removing schemas from the collection.
// 1 - Remove a schema by index:
schemas.removeAt(2);
// 2 - Remove a schema by value:
schemas.remove("http://www.w3.org/2001/XMLSchema");
// 3 - Use the "Clear" method to empty the collection at once.
schemas.clear();
Assert.assertEquals(schemas.getCount(), 0);