Search in sources :

Example 31 with XMLResource

use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.

the class TestXPathOpOrSpecialCase method storeXML.

/**
 * Store the XML string into the specified collection and document.
 * @param collection The target collection.
 * @param documentName The target document name.
 * @param content The XML content to be stored.
 * @throws XMLDBException See {@link XMLDBException}.
 */
private void storeXML(final Collection collection, final String documentName, final String content) throws XMLDBException {
    final XMLResource doc = (XMLResource) collection.createResource(documentName, "XMLResource");
    doc.setContent(content);
    collection.storeResource(doc);
}
Also used : XMLResource(org.xmldb.api.modules.XMLResource)

Example 32 with XMLResource

use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.

the class NamespaceUpdateTest method setUp.

@Before
public void setUp() throws ClassNotFoundException, IllegalAccessException, InstantiationException, XMLDBException {
    // initialize driver
    final CollectionManagementService service = (CollectionManagementService) existEmbeddedServer.getRoot().getService("CollectionManagementService", "1.0");
    testCollection = service.createCollection("test");
    assertNotNull(testCollection);
    final XMLResource doc = (XMLResource) testCollection.createResource("namespace-updates.xml", "XMLResource");
    doc.setContent(namespaces);
    testCollection.storeResource(doc);
}
Also used : CollectionManagementService(org.xmldb.api.modules.CollectionManagementService) XMLResource(org.xmldb.api.modules.XMLResource) Before(org.junit.Before)

Example 33 with XMLResource

use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.

the class PersistentDescendantOrSelfNodeKindTest method storeTestDoc.

@BeforeClass
public static void storeTestDoc() throws XMLDBException {
    final Collection root = existEmbeddedServer.getRoot();
    final XMLResource res = (XMLResource) root.createResource(TEST_DOCUMENT_NAME, "XMLResource");
    res.setContent(TEST_DOCUMENT);
    root.storeResource(res);
}
Also used : Collection(org.xmldb.api.base.Collection) XMLResource(org.xmldb.api.modules.XMLResource) BeforeClass(org.junit.BeforeClass)

Example 34 with XMLResource

use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.

the class SpecialNamesTest method storeXMLStringAndGetQueryService.

/**
 * stores XML String and get Query Service
 * @param documentName to be stored in the DB
 * @param content to be stored in the DB
 * @return the XQuery Service
 * @throws XMLDBException
 */
@SuppressWarnings("unused")
private XQueryService storeXMLStringAndGetQueryService(String documentName, String content) throws XMLDBException {
    XMLResource doc = (XMLResource) testCollection.createResource(documentName, "XMLResource");
    doc.setContent(content);
    testCollection.storeResource(doc);
    XQueryService service = (XQueryService) testCollection.getService("XPathQueryService", "1.0");
    return service;
}
Also used : XQueryService(org.xmldb.api.modules.XQueryService) XMLResource(org.xmldb.api.modules.XMLResource)

Example 35 with XMLResource

use of org.xmldb.api.modules.XMLResource in project exist by eXist-db.

the class UnionTest method storeCollectionConfig.

private void storeCollectionConfig() throws XMLDBException {
    final Collection colConfig = getOrCreateCollection("/db/system/config/db/" + TEST_COLLECTION_NAME);
    final XMLResource docConfig = (XMLResource) colConfig.createResource(DEFAULT_COLLECTION_CONFIG_FILE, "XMLResource");
    docConfig.setContent(INDEX_CONFIG);
    colConfig.storeResource(docConfig);
}
Also used : Collection(org.xmldb.api.base.Collection) XMLResource(org.xmldb.api.modules.XMLResource)

Aggregations

XMLResource (org.xmldb.api.modules.XMLResource)142 Collection (org.xmldb.api.base.Collection)56 ResourceSet (org.xmldb.api.base.ResourceSet)56 XPathQueryService (org.xmldb.api.modules.XPathQueryService)49 Test (org.junit.Test)33 Resource (org.xmldb.api.base.Resource)24 XQueryService (org.xmldb.api.modules.XQueryService)23 Node (org.w3c.dom.Node)22 CollectionManagementService (org.xmldb.api.modules.CollectionManagementService)20 EXistXPathQueryService (org.exist.xmldb.EXistXPathQueryService)18 Document (org.w3c.dom.Document)16 XMLDBException (org.xmldb.api.base.XMLDBException)15 EXistResource (org.exist.xmldb.EXistResource)9 EXistXQueryService (org.exist.xmldb.EXistXQueryService)9 BinaryResource (org.xmldb.api.modules.BinaryResource)9 Path (java.nio.file.Path)8 Before (org.junit.Before)8 Element (org.w3c.dom.Element)8 Source (javax.xml.transform.Source)7 SAXSerializer (org.exist.util.serializer.SAXSerializer)7