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

Allow specifying xml namespace prefix #195

Merged
merged 6 commits into from
Oct 29, 2019

Conversation

JordonPhillips
Copy link
Contributor

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.

@@ -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-]*)?$")
Copy link
Contributor

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.

@JordonPhillips JordonPhillips requested a review from kstich October 29, 2019 16:59
@@ -221,8 +221,9 @@ following document:
``-``. Values for an ``xmlName`` adhere to the following ABNF.

.. productionlist:: smithy
xml_name :(ALPHA / "_")
name :(ALPHA / "_")
Copy link
Member

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?

``-``. Values for ``prefix`` adhere to the following ABNF.

.. productionlist:: smithy
prefix :(ALPHA / "_")
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

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.

@JordonPhillips JordonPhillips merged commit 309ef22 into smithy-lang:master Oct 29, 2019
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