-
Notifications
You must be signed in to change notification settings - Fork 167
XML Namespace Declarations for XPath Expressions #2253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
predic8
merged 20 commits into
master
from
xml-namespace-declarations-for-xpath-expressions
Nov 5, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
ce94e26
feat: XML namespace declarations for XPath
predic8 7b0b78b
refactor: minor
predic8 f0df650
refactor: minor
predic8 6347d21
refactor: minor
predic8 74ddf93
refactor: minor
predic8 150ab96
before merge
predic8 bb7c9dc
refactor: minor
predic8 a3075f9
refactor: minor
predic8 b808382
refactor: minor
predic8 7a65c48
refactor: minor
predic8 c9e9734
add test cases
christiangoerdes 4aebbb0
add test case for header (fails)
christiangoerdes aa3ad0d
add test case for header
christiangoerdes 429e21a
refactor: minor
predic8 79d26cf
Merge remote-tracking branch 'origin/xml-namespace-declarations-for-x…
predic8 18f1f0c
Merge branch 'master' into xml-namespace-declarations-for-xpath-expre…
predic8 8e27a36
refactor: xmlConfig instead of just namespaces
predic8 4b7b720
Merge remote-tracking branch 'origin/xml-namespace-declarations-for-x…
predic8 d05683e
refactor: minor
predic8 04a6490
refactor: minor
predic8 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
core/src/main/java/com/predic8/membrane/core/config/xml/Namespaces.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| /* Copyright 2025 predic8 GmbH, www.predic8.com | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. */ | ||
|
|
||
| package com.predic8.membrane.core.config.xml; | ||
|
|
||
| import com.predic8.membrane.annot.*; | ||
|
|
||
| import javax.xml.namespace.*; | ||
| import java.util.*; | ||
|
|
||
| import static javax.xml.XMLConstants.NULL_NS_URI; | ||
|
|
||
| @MCElement(name="namespaces", topLevel = false) | ||
| public class Namespaces { | ||
|
|
||
| private List<Namespace> namespaces; | ||
| private final NamespaceContextImpl nsContext = new NamespaceContextImpl(); | ||
|
|
||
| public NamespaceContext getNamespaceContext() { | ||
| return nsContext; | ||
| } | ||
|
|
||
| /** | ||
| * @description Defines XML namespace mappings (prefix to URI) for use in XPath expressions. | ||
| */ | ||
|
predic8 marked this conversation as resolved.
|
||
| @MCChildElement(allowForeign = false) | ||
| public void setNamespace(List<Namespace> namespace) { | ||
| this.namespaces = namespace; | ||
| } | ||
|
|
||
| public List<Namespace> getNamespace() { | ||
| return namespaces; | ||
| } | ||
|
|
||
| @MCElement(name = "namespace", topLevel = false, id = "xml-namespace") | ||
| public static class Namespace { | ||
|
|
||
| public String prefix; | ||
| public String uri; | ||
|
|
||
| public Namespace() { | ||
| } | ||
|
|
||
| public String getPrefix() { | ||
| return prefix; | ||
| } | ||
|
|
||
| @MCAttribute | ||
| public void setPrefix(String prefix) { | ||
| this.prefix = prefix; | ||
| } | ||
|
|
||
| public String getUri() { | ||
| return uri; | ||
| } | ||
|
|
||
| @MCAttribute | ||
| public void setUri(String uri) { | ||
| this.uri = uri; | ||
| } | ||
| } | ||
|
|
||
| class NamespaceContextImpl implements NamespaceContext { | ||
|
|
||
| @Override | ||
| public String getNamespaceURI(String prefix) { | ||
| return namespaces.stream() | ||
| .filter(ns -> prefix.equals(ns.prefix)) | ||
| .findFirst() | ||
| .map(ns -> ns.uri) | ||
| .orElse(NULL_NS_URI); | ||
| } | ||
|
|
||
| @Override | ||
| public String getPrefix(String namespaceURI) { | ||
| return namespaces.stream() | ||
| .filter(ns -> namespaceURI.equals(ns.uri)) | ||
| .map(ns -> ns.prefix) | ||
| .findFirst() | ||
| .orElse(null); | ||
| } | ||
|
|
||
| @Override | ||
| public Iterator<String> getPrefixes(String namespaceURI) { | ||
| return namespaces.stream() | ||
| .filter(ns -> namespaceURI.equals(ns.uri)) | ||
| .map(ns -> ns.prefix) | ||
| .iterator(); | ||
| } | ||
| } | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
core/src/main/java/com/predic8/membrane/core/config/xml/XmlConfig.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package com.predic8.membrane.core.config.xml; | ||
|
|
||
| import com.predic8.membrane.annot.*; | ||
|
|
||
| @MCElement(name="xmlConfig",topLevel = true) | ||
| public class XmlConfig { | ||
|
|
||
| private Namespaces namespaces; | ||
|
|
||
| @MCChildElement | ||
| public void setNamespaces(Namespaces namespaces) { | ||
| this.namespaces = namespaces; | ||
| } | ||
|
|
||
| public Namespaces getNamespaces() { | ||
| return namespaces; | ||
| } | ||
| } | ||
|
predic8 marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/src/main/java/com/predic8/membrane/core/interceptor/XMLSupport.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| /* Copyright 2025 predic8 GmbH, www.predic8.com | ||
|
|
||
| Licensed under the Apache License, Version 2.0 (the "License"); | ||
| you may not use this file except in compliance with the License. | ||
| You may obtain a copy of the License at | ||
|
|
||
| http://www.apache.org/licenses/LICENSE-2.0 | ||
|
|
||
| Unless required by applicable law or agreed to in writing, software | ||
| distributed under the License is distributed on an "AS IS" BASIS, | ||
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| See the License for the specific language governing permissions and | ||
| limitations under the License. */ | ||
|
|
||
| package com.predic8.membrane.core.interceptor; | ||
|
|
||
| import com.predic8.membrane.core.config.xml.*; | ||
|
|
||
| public interface XMLSupport { | ||
|
|
||
| void setXmlConfig(XmlConfig xmlConfig); | ||
|
|
||
| XmlConfig getXmlConfig(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.