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 stopNodes to work with removeNSPrefix (#607) #608

Merged

Conversation

candrews
Copy link
Contributor

Purpose / Goal

The stopNodes option currently doesn't work with the remoteNSPrefix option. This pull request fixes that issue and adds tests to demonstrate the fix.

Type

Please mention the type of PR

  • Bug Fix
  • Refactoring / Technology upgrade
  • New Feature

@candrews candrews force-pushed the stopNodes-removeNSPrefix branch from 89130cd to 5574156 Compare August 30, 2023 21:38
@amitguptagwl
Copy link
Member

Thanks for the PR. I'll check it ASAP

@@ -280,6 +280,7 @@ const parseXml = function(xmlData) {
}else {//Opening tag
let result = readTagExp(xmlData,i, this.options.removeNSPrefix);
let tagName= result.tagName;
const tagNameWithNamespace = result.tagNamespace ? result.tagNamespace + ":" + result.tagName : result.tagName;
Copy link
Member

Choose a reason for hiding this comment

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

This variable name gives impression that it always has namespace in it. I believe, it should be se to tagName. The original tagName variable can be renamed accordingly. Moreover, it would be good if this code is present in readTagExp so reduce an extra operation of comparison and concatenation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original tagName variable can be renamed accordingly.

Pehaps the new name for that variable should be tagNameWithoutNamespace

Moreover, it would be good if this code is present in readTagExp so reduce an extra operation of comparison and concatenation.

I'll see what I can do

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this PR, and I think the approach make sense and hopefully addresses your concerns.

tagName is the tag name. If removeNSPrefix, then tagName never has a namespace; otherwise, it will have a namespace if there is a namespace.

tagNameWithNamespace is the tag name with namespace if there is a namespace. It's value doesn't depend on removeNSPrefix.

The work is done in readTagExp and it avoids the additional comparison / concatenation.

Copy link
Member

Choose a reason for hiding this comment

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

So you mean tagNameWithNamespace is actually originalTagName or rawTagName which may or may not have name space?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, tagNameWithNamespace is the tag with a namespace (if it has a namespace).

I could use other names for that variable, such as originalTagName or rawTagName - whatever you'd prefer.

As they say, naming things is one the hard problems of computer science

Copy link
Member

@amitguptagwl amitguptagwl Sep 8, 2023

Choose a reason for hiding this comment

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

I completely agree and I faced it. But ...WithNameSpace is misleading that's why I'm highlighting it. I think anyone from originalTagName or rawTagName would be better. Both define the purpose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've updated this PR to use rawTagName as the name for this variable :)

Is there anything else I can do to help get this PR merged? I'm quite eager to use this fix in my project

@candrews candrews force-pushed the stopNodes-removeNSPrefix branch 2 times, most recently from 4cb109c to 922b51f Compare September 5, 2023 16:46
Signed-off-by: Craig Andrews <candrews@integralblue.com>
@candrews candrews force-pushed the stopNodes-removeNSPrefix branch from 922b51f to 37dfbe2 Compare September 8, 2023 14:08
@coveralls
Copy link

Coverage Status

coverage: 98.239% (+0.01%) from 98.226% when pulling 37dfbe2 on candrews:stopNodes-removeNSPrefix into 3c9e9fe on NaturalIntelligence:master.

@amitguptagwl amitguptagwl merged commit ae99fc6 into NaturalIntelligence:master Sep 10, 2023
@amitguptagwl
Copy link
Member

amitguptagwl commented Sep 10, 2023

Thanks for your PR. However, this may take little time to publish as I would like to provide a single publish that includes some open bugs.

@candrews
Copy link
Contributor Author

I'm really eager to be able to use this bug fix. What open bugs are blocking the next release? Maybe I could help address them to move things along.

@amitguptagwl
Copy link
Member

Thanks @candrews . I'll fix #610 this weekend and publish.

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.

3 participants