-
Notifications
You must be signed in to change notification settings - Fork 220
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 specifying xml namespace prefix #195
Allow specifying xml namespace prefix #195
Conversation
0488166
to
4241042
Compare
@@ -156,7 +156,7 @@ structure xmlFlattened {} | |||
/// used in the model. | |||
@trait | |||
@tags(["diff.error.const"]) | |||
@pattern("^[a-zA-Z_][a-zA-Z_0-9-]*$") | |||
@pattern("^[a-zA-Z_][a-zA-Z_0-9-]*(:[a-zA-Z_][a-zA-Z_0-9-]*)?$") |
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 pattern update should be reflected in the xmlName
trait spec's ABNF.
docs/source/spec/xml.rst
Outdated
@@ -221,8 +221,9 @@ following document: | |||
``-``. Values for an ``xmlName`` adhere to the following ABNF. | |||
|
|||
.. productionlist:: smithy | |||
xml_name :(ALPHA / "_") | |||
name :(ALPHA / "_") |
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.
Do we already use the name production anywhere else? I think this might break how we link to them across "smithy" production lists. Maybe xml_name
and xml_identifier
?
docs/source/spec/xml.rst
Outdated
``-``. Values for ``prefix`` adhere to the following ABNF. | ||
|
||
.. productionlist:: smithy | ||
prefix :(ALPHA / "_") |
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.
xml_prefix?
@@ -75,6 +91,11 @@ public Builder uri(String uri) { | |||
return this; | |||
} | |||
|
|||
public Builder prefix(String prefix) { | |||
this.prefix = Objects.requireNonNull(prefix); |
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.
You should allow null
in order to clear out the prefix.
Builder traitBuilder = builder() | ||
.sourceLocation(getSourceLocation()) | ||
.uri(getUri()); | ||
getPrefix().ifPresent(traitBuilder::prefix); |
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.
Given that you should allow nulls for this value in the builder anyways (it's optional), you could just chain here and pass in the potentially null property of prefix
.
This updates the xmlnamespace trait to allow specifying a prefix to
pull the namespace into. It further updates the pattern for the
xmlname trait to allow specifying a name with a prefix, e.g.
myprefix:myname
.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.