-
Notifications
You must be signed in to change notification settings - Fork 2
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
Allow nulls for write elements in MXSerializer #29
Allow nulls for write elements in MXSerializer #29
Conversation
@garydgregory thanks ... I afraid thet we will have a conflict with my PR #28 If you let me I first merge my PR and that you can rebase your |
8a472f5
to
e03c11f
Compare
@slawekjaranowski |
@michael-o @elharo can you also look at it 😄 |
I'd like to see this rebased first... |
After the rebase is done let's try MJAVADOC again with a snapshot of Plexus XML and see what happens. |
e03c11f
to
5a5581a
Compare
I rebased on master again. |
new MXSerializer().writeElementContent(null, stringWriter); | ||
new MXSerializer().writeAttributeValue(null, stringWriter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should support ?
new MXSerializer().writeElementContent("value", null);
new MXSerializer().writeAttributeValue("value", null);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add some of assertions for what content of stringWriter
should be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/main/java/org/codehaus/plexus/util/xml/pull/MXSerializer.java
Outdated
Show resolved
Hide resolved
Please also change of PR / commit message to show what really is changed, what is root cause eg
|
Test:
output:
|
What about the pretty printer? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some suggestion. I don't see anything actually incorrect here.
} else { | ||
if (value != null) { | ||
// .[apostrophe and <, & escaped], | ||
final char quot = attributeUseApostrophe ? '\'' : '"'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why we even make a choice here. Would be simpler to pick one and stick with it.
out.write(">"); | ||
} else if (ch == quot) { | ||
if (i > pos) out.write(value.substring(pos, i)); | ||
out.write(quotEntity); | ||
pos = i + 1; | ||
} else if (ch < 32) { | ||
// in XML 1.0 only legal character are #x9 | #xA | #xD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
legal C0 characters
// pass through | ||
|
||
// } else if(ch == 13) { //escape | ||
// and they must be escaped otherwise in attribute value they are normalized to spaces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
escaped;
pos = i + 1; | ||
} else { | ||
throw new IllegalStateException( | ||
"character " + Integer.toString(ch) + " is not allowed in output" + getLocation()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IllegalArgumentException
} else { | ||
throw new IllegalStateException( | ||
"character " + Integer.toString(ch) + " is not allowed in output" + getLocation()); | ||
// in XML 1.1 legal are [#x1-#xD7FF] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd delete all this commented code
if (ch == 9 || ch == 10 || ch == 13) { | ||
// pass through | ||
|
||
// } else if(ch == 13) { //escape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete commented code
5a5581a
to
b2263d5
Compare
@elharo Thank you for your comments. I'll let the Maven team address those since I feel they are out of scope for this PR. |
* Tests MJAVADOC-793. | ||
*/ | ||
@Test | ||
public void testMJAVADOC793() throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be renamed. This is not related to the Javadoc plugin. IT simply does not allow null values. testNullValues()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: testWriteNullValues()
.
you right if needed should be fixed in separate PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks OK please chenge test name and commit PR title
b2263d5
to
5a58475
Compare
@michael-o I hope your doubts was resolved, so I will merge and process forward |
@@ -55,4 +56,19 @@ private String expectedOutput() { | |||
out.append("</root>"); | |||
return out.toString(); | |||
} | |||
|
|||
/** | |||
* Tests MJAVADOC-793. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that comment is wrong here as well.
Yes, but my question about the |
https://issues.apache.org/jira/browse/MJAVADOC-793
Allow nulls for write elements in
MXSerializer
.