CustomXmlSchemaCollection class
CustomXmlSchemaCollection class
A collection of strings that represent XML schemas that are associated with a custom XML part. 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.schemas property.
Properties
Name | Description |
---|---|
count | Gets the number of elements contained in the collection. |
this[] |
Methods
Name | Description |
---|---|
add(value) | Adds an item to the collection. |
clear() | Removes all elements from the collection. |
clone() | Makes a deep clone of this object. |
indexOf(value) | Returns the zero-based index of the specified value in the collection. |
remove(name) | Removes the specified value from the collection. |
removeAt(index) | Removes a value at the specified index. |
Examples
Shows how to work with an XML schema collection.
let doc = new aw.Document();
let xmlPartId = `{${Guid.newGuid().toString()}}`;
let xmlPartContent = "<root><text>Hello, World!</text></root>";
let xmlPart = doc.customXmlParts.add(xmlPartId, xmlPartContent);
// Add an XML schema association.
xmlPart.schemas.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.
let schemas = xmlPart.schemas.clone();
schemas.add("http://www.w3.org/2001/XMLSchema-instance");
schemas.add("http://schemas.microsoft.com/office/2006/metadata/contentType");
expect(schemas.count).toEqual(3);
expect(schemas.indexOf("http://schemas.microsoft.com/office/2006/metadata/contentType")).toEqual(2);
// Enumerate the schemas and print each element.
for (let schema of schemas) {
console.log(schema);
}
// 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();
expect(schemas.count).toEqual(0);
See Also
- module Aspose.Words.Markup
- class CustomXmlPart
- property CustomXmlPart.schemas