Skip to content
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

fix: support prefixed names in patterns #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cjmamo
Copy link

@cjmamo cjmamo commented Nov 27, 2021

re-add PatternParserTest

@cjmamo
Copy link
Author

cjmamo commented Nov 27, 2021

@elharo: the next version of Smooks will heavily rely on PatternParser for its XPath evaluations. We'd appreciate it if this PR is merged so that we don't need to fork PatternParser for evaluating prefixes in paths.

@elharo elharo self-requested a review November 27, 2021 12:26
Copy link
Contributor

@elharo elharo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pattern package is not very well documented, designed, or supported. If not for backwards compatibility, I would have deleted it long ago. I'll look at this, but it's unlikely this is the only change you'll need here. You might be better served by forking this. I'm not sure the existing design, API, and codebase is fixable or maintainable.

@cjmamo
Copy link
Author

cjmamo commented Nov 27, 2021

Are there plans to replace the pattern package in the next version of Jaxen? We found it very useful for our purposes and couldn't find a better way to support XSLT patterns with Jaxen.

@elharo
Copy link
Contributor

elharo commented Nov 28, 2021

There are no such plans. I was planning on deleting it eventually. It has no tests currently, and you're the first person I've ever heard from whose using it.

@@ -0,0 +1,77 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed

*
* ====================================================================
*
* Copyright 2000-2002 bob mcwhirter & James Strachan.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2021 The Jaxen Project

* individuals on behalf of the Jaxen Project and was originally
* created by bob mcwhirter <bob@werken.com> and
* James Strachan <jstrachan@apache.org>. For more information on the
* Jaxen Project, please see <http://www.jaxen.org/>.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* James Strachan <jstrachan@apache.org>. For more information on the
* Jaxen Project, please see <http://www.jaxen.org/>.
*
* $Id$
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

*
* @author Claude Mamo
*/
public class NameNamespaceCompositeTest extends NodeTest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QualifiedNameTest or perhaps PrefixedNameTest


public String getText()
{
return namespaceTest.getText() + nameTest.getText();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should there be a separator here?
@OverRide

path.setNodeTest( new NameTest( localName, nodeType ) );
// XXXX: should support namespace in the test too
NameTest nameTest = new NameTest( localName, nodeType );
NodeTest nodeTest;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be a little clearer if you pushed this into the if-block and called setNodeTest from within each branch.

*
* ====================================================================
*
* Copyright 2000-2002 bob mcwhirter & James Strachan.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

"+"
};

public PatternParserTest(String name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

XPathFunctionContext.getInstance(),
new SimpleVariableContext(),
new DocumentNavigator());
assertTrue(pattern.matches(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument().
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

break this statement up with some local variables for clarity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants