Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions exist-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,7 @@
<include>src/test/xquery/base-uri.xql</include>
<include>src/test/xquery/parenthesizedLocationStep.xml</include>
<include>src/test/xquery/tail-recursion.xml</include>
<include>src/test/xquery/indexing/indexes-base-uri.xq</include>
<include>src/test/xquery/maps/maps.xqm</include>
<include>src/test/xquery/numbers/format-numbers.xql</include>
<include>src/test/xquery/util/util.xml</include>
Expand Down Expand Up @@ -894,6 +895,7 @@
<include>src/main/java/org/exist/dom/QName.java</include>
<include>src/main/java/org/exist/dom/memtree/AbstractCharacterData.java</include>
<include>src/main/java/org/exist/dom/memtree/AttrImpl.java</include>
<include>src/main/java/org/exist/dom/memtree/CDATASectionImpl.java</include>
<include>src/main/java/org/exist/dom/memtree/CommentImpl.java</include>
<include>src/main/java/org/exist/dom/memtree/DocumentBuilderReceiver.java</include>
<include>src/main/java/org/exist/dom/memtree/DocumentImpl.java</include>
Expand All @@ -913,6 +915,7 @@
<include>src/test/java/org/exist/dom/persistent/BasicNodeSetTest.java</include>
<include>src/main/java/org/exist/dom/persistent/BinaryDocument.java</include>
<include>src/test/java/org/exist/dom/persistent/CDataIntergationTest.java</include>
<include>src/main/java/org/exist/dom/persistent/CDATASectionImpl.java</include>
<include>src/main/java/org/exist/dom/persistent/CommentImpl.java</include>
<include>src/test/java/org/exist/dom/persistent/CommentTest.java</include>
<include>src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java</include>
Expand Down Expand Up @@ -1115,6 +1118,7 @@
<include>src/test/java/org/exist/util/CollationsTest.java</include>
<include>src/main/java/org/exist/util/Configuration.java</include>
<include>src/test/java/org/exist/util/DOMSerializerTest.java</include>
<include>src/main/java/org/exist/util/EXistURISchemeURIResolver.java</include>
<include>src/test/java/org/exist/util/LeasableTest.java</include>
<include>src/test/java/org/exist/util/MediaTypeResolverTest.java</include>
<include>src/main/java/org/exist/util/MimeTable.java</include>
Expand Down Expand Up @@ -1417,6 +1421,7 @@
<include>src/test/java/org/exist/xquery/functions/validate/JingSchematronTest.java</include>
<include>src/test/java/org/exist/xquery/functions/validate/JingXsdTest.java</include>
<include>src/main/java/org/exist/xquery/functions/validation/Jaxp.java</include>
<include>src/main/java/org/exist/xquery/functions/validation/Shared.java</include>
<include>src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java</include>
<include>src/main/java/org/exist/xquery/functions/xmldb/FunXCollection.java</include>
<include>src/main/java/org/exist/xquery/functions/xmldb/XMLDBGetMimeType.java</include>
Expand Down Expand Up @@ -1522,6 +1527,7 @@
<exclude>src/test/xquery/pi.xqm</exclude>
<exclude>src/test/xquery/tail-recursion.xml</exclude>
<exclude>src/test/xquery/type-promotion.xqm</exclude>
<exclude>src/test/xquery/indexing/indexes-base-uri.xq</exclude>
<exclude>src/test/xquery/maps/maps.xqm</exclude>
<exclude>src/test/xquery/numbers/format-numbers.xql</exclude>
<exclude>src/test/xquery/securitymanager/acl.xqm</exclude>
Expand Down Expand Up @@ -1616,7 +1622,8 @@
<exclude>src/main/java/org/exist/dom/QName.java</exclude>
<exclude>src/main/java/org/exist/dom/memtree/AbstractCharacterData.java</exclude>
<exclude>src/main/java/org/exist/dom/memtree/AttrImpl.java</exclude>
<include>src/main/java/org/exist/dom/memtree/CommentImpl.java</include>
<exclude>src/main/java/org/exist/dom/memtree/CDATASectionImpl.java</exclude>
<exclude>src/main/java/org/exist/dom/memtree/CommentImpl.java</exclude>
<exclude>src/main/java/org/exist/dom/memtree/DocumentBuilderReceiver.java</exclude>
<exclude>src/main/java/org/exist/dom/memtree/DocumentImpl.java</exclude>
<exclude>src/test/java/org/exist/dom/memtree/DocumentImplTest.java</exclude>
Expand All @@ -1643,6 +1650,7 @@
<exclude>src/test/java/org/exist/dom/persistent/BasicNodeSetTest.java</exclude>
<exclude>src/main/java/org/exist/dom/persistent/BinaryDocument.java</exclude>
<exclude>src/test/java/org/exist/dom/persistent/CDataIntergationTest.java</exclude>
<exclude>src/main/java/org/exist/dom/persistent/CDATASectionImpl.java</exclude>
<exclude>src/main/java/org/exist/dom/persistent/CommentImpl.java</exclude>
<exclude>src/test/java/org/exist/dom/persistent/CommentTest.java</exclude>
<exclude>src/test/java/org/exist/dom/persistent/DefaultDocumentSetTest.java</exclude>
Expand Down Expand Up @@ -1913,6 +1921,7 @@
<exclude>src/test/java/org/exist/util/CollectionOfArrayIteratorTest.java</exclude>
<exclude>src/main/java/org/exist/util/Configuration.java</exclude>
<exclude>src/test/java/org/exist/util/DOMSerializerTest.java</exclude>
<exclude>src/main/java/org/exist/util/EXistURISchemeURIResolver.java</exclude>
<exclude>src/main/java/org/exist/util/IPUtil.java</exclude>
<exclude>src/main/java/org/exist/util/JREUtil.java</exclude>
<exclude>src/test/java/org/exist/util/LeasableTest.java</exclude>
Expand Down Expand Up @@ -2254,6 +2263,7 @@
<exclude>src/test/java/org/exist/xquery/functions/validate/JingSchematronTest.java</exclude>
<exclude>src/test/java/org/exist/xquery/functions/validate/JingXsdTest.java</exclude>
<exclude>src/main/java/org/exist/xquery/functions/validation/Jaxp.java</exclude>
<exclude>src/main/java/org/exist/xquery/functions/validation/Shared.java</exclude>
<exclude>src/test/java/org/exist/xquery/functions/xmldb/AbstractXMLDBTest.java</exclude>
<exclude>src/test/java/org/exist/xquery/functions/xmldb/DbStore2Test.java</exclude>
<exclude>src/main/java/org/exist/xquery/functions/xmldb/FunXCollection.java</exclude>
Expand Down Expand Up @@ -2848,4 +2858,4 @@ The BaseX Team. The original license statement is also included below.]]></pream
</profile>
</profiles>

</project>
</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* admin@evolvedbinary.com
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand All @@ -25,8 +49,11 @@
import org.exist.xquery.value.Type;
import org.w3c.dom.CDATASection;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import org.w3c.dom.Text;

import javax.annotation.Nullable;


/**
* Represents a CDATA section.
Expand All @@ -48,6 +75,15 @@ public int getItemType() {
return Type.CDATA_SECTION;
}

@Override
public @Nullable String getBaseURI() {
@Nullable final Node parent = getParentNode();
if (parent == null) {
return null;
}
return parent.getBaseURI();
}

@Override
public Text splitText(final int offset) throws DOMException {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import org.exist.util.XMLString;
import org.exist.util.pool.NodePool;
import org.exist.util.serializer.AttrList;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.Expression;
import org.w3c.dom.*;

Expand Down Expand Up @@ -425,7 +426,12 @@ public boolean isId() {
public @Nullable String getBaseURI() {
@Nullable final Element e = getOwnerElement();
if (e != null) {
return e.getBaseURI();
@Nullable String strBaseUri = e.getBaseURI();
if (strBaseUri != null && strBaseUri.startsWith("/db/")) {
// Must be a URI!
strBaseUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + strBaseUri;
}
return strBaseUri;
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* admin@evolvedbinary.com
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -27,12 +51,15 @@
import org.exist.util.ByteConversion;
import org.exist.util.UTF8;
import org.exist.util.XMLString;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.Expression;
import org.w3c.dom.CDATASection;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
import org.w3c.dom.Text;

import javax.annotation.Nullable;

public class CDATASectionImpl extends AbstractCharacterData implements CDATASection {

public CDATASectionImpl() {
Expand Down Expand Up @@ -77,6 +104,20 @@ public CDATASectionImpl(final Expression expression, final String data) {
}

@Override
public @Nullable String getBaseURI() {
@Nullable final Node parent = getParentNode();
if (parent != null) {
@Nullable String strBaseUri = parent.getBaseURI();
if (strBaseUri != null && strBaseUri.startsWith("/db/")) {
// Must be a URI!
strBaseUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + strBaseUri;
}
return strBaseUri;
} else {
return null;
}
}

/**
* Serializes a (persistent DOM) CDATA Section to a byte array
*
Expand All @@ -94,6 +135,7 @@ public CDATASectionImpl(final Expression expression, final String data) {
* @return the returned byte array after use must be returned to the ByteArrayPool
* by calling {@link ByteArrayPool#releaseByteArray(byte[])}
*/
@Override
public byte[] serialize() {
final int nodeIdLen = nodeId.size();
final byte[] data = ByteArrayPool.getByteArray(LENGTH_SIGNATURE_LENGTH + NodeId.LENGTH_NODE_ID_UNITS +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
import org.exist.storage.Signatures;
import org.exist.util.ByteConversion;
import org.exist.util.pool.NodePool;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.Expression;
import org.w3c.dom.Comment;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -92,7 +93,12 @@ public String toString() {
public @Nullable String getBaseURI() {
@Nullable final Node parent = getParentNode();
if (parent != null) {
return parent.getBaseURI();
@Nullable String strBaseUri = parent.getBaseURI();
if (strBaseUri != null && strBaseUri.startsWith("/db/")) {
// Must be a URI!
strBaseUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + strBaseUri;
}
return strBaseUri;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1681,7 +1681,7 @@ public Node renameNode(final Node n, final String namespaceURI, final String qua

@Override
public String getBaseURI() {
return getURI().toString();
return XmldbURI.EMBEDDED_SERVER_URI_PREFIX + getURI().getCollectionPath();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2003,7 +2003,12 @@ public void setIdAttributeNode(final Attr idAttr, final boolean isId) throws DOM
public @Nullable String getBaseURI() {
@Nullable final XmldbURI baseURI = calculateBaseURI();
if (baseURI != null) {
return baseURI.toString();
String strBaseUri = baseURI.toString();
if (strBaseUri.startsWith("/db/")) {
// Must be a URI!
strBaseUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + baseURI;
}
return strBaseUri;
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.exist.storage.Signatures;
import org.exist.util.ByteConversion;
import org.exist.util.pool.NodePool;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.Expression;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -154,7 +155,12 @@ public void setData(final String data) {
public @Nullable String getBaseURI() {
@Nullable final StoredNode parent = getParentStoredNode();
if (parent != null) {
return parent.getBaseURI();
@Nullable String strBaseUri = parent.getBaseURI();
if (strBaseUri != null && strBaseUri.startsWith("/db/")) {
// Must be a URI!
strBaseUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + strBaseUri;
}
return strBaseUri;
} else {
return getOwnerDocument().getBaseURI();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.exist.util.ByteConversion;
import org.exist.util.UTF8;
import org.exist.util.pool.NodePool;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.Expression;
import org.w3c.dom.DOMException;
import org.w3c.dom.Node;
Expand Down Expand Up @@ -180,7 +181,12 @@ public Text splitText(final int offset) throws DOMException {
public @Nullable String getBaseURI() {
@Nullable final Node parent = getParentNode();
if (parent != null) {
return parent.getBaseURI();
@Nullable String strBaseUri = parent.getBaseURI();
if (strBaseUri != null && strBaseUri.startsWith("/db/")) {
// Must be a URI!
strBaseUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + strBaseUri;
}
return strBaseUri;
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,28 @@
/*
* Elemental
* Copyright (C) 2024, Evolved Binary Ltd
*
* admin@evolvedbinary.com
* https://www.evolvedbinary.com | https://www.elemental.xyz
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; version 2.1.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* NOTE: Parts of this file contain code from 'The eXist-db Authors'.
* The original license header is included below.
*
* =====================================================================
*
* eXist-db Open Source Native XML Database
* Copyright (C) 2001 The eXist-db Authors
*
Expand Down Expand Up @@ -56,6 +80,8 @@ private String rewriteScheme(String uri) {
uri = uri.replace("exist://localhost/db", "/db");
} else if (uri.startsWith("exist://")) {
uri = uri.replace("exist://", "xmldb:exist://");
} else if (uri.startsWith("exist:/")) {
uri = uri.replace("exist:/", "xmldb:exist:///");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
import net.sf.saxon.s9api.QName;
import net.sf.saxon.s9api.XdmValue;
import org.exist.dom.memtree.NamespaceNode;
import org.exist.xmldb.XmldbURI;
import org.exist.xquery.ErrorCodes;
import org.exist.xquery.XPathException;
import org.exist.xquery.XQueryContext;
Expand Down Expand Up @@ -490,7 +491,13 @@ private Tuple2<String, Source> getStylesheet(final MapType options) throws XPath
final List<Tuple2<String, Source>> results = new ArrayList<>(1);
final Optional<String> stylesheetLocation = Options.STYLESHEET_LOCATION.get(options).map(StringValue::getStringValue);
if (stylesheetLocation.isPresent()) {
results.add(Tuple(stylesheetLocation.get(), resolveStylesheetLocation(stylesheetLocation.get())));
final String strStylesheetLocationUri;
if (stylesheetLocation.get().startsWith("/db/")) {
strStylesheetLocationUri = XmldbURI.EMBEDDED_SERVER_URI_PREFIX + stylesheetLocation.get();
} else {
strStylesheetLocationUri = stylesheetLocation.get();
}
results.add(Tuple(strStylesheetLocationUri, resolveStylesheetLocation(stylesheetLocation.get())));
}

final Optional<Node> stylesheetNode = Options.STYLESHEET_NODE.get(options).map(NodeValue::getNode);
Expand Down
Loading
Loading