Skip to content

Allow specifying xml namespace prefix#195

Merged
JordonPhillips merged 6 commits intosmithy-lang:masterfrom
JordonPhillips:xmlns-prefix
Oct 29, 2019
Merged

Allow specifying xml namespace prefix#195
JordonPhillips merged 6 commits intosmithy-lang:masterfrom
JordonPhillips:xmlns-prefix

Conversation

@JordonPhillips
Copy link
Copy Markdown
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.

@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
Copy Markdown
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

.. productionlist:: smithy
xml_name :(ALPHA / "_")
name :(ALPHA / "_")
Copy link
Copy Markdown
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
Copy Markdown
Member

Choose a reason for hiding this comment

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

xml_prefix?

}

public Builder prefix(String prefix) {
this.prefix = Objects.requireNonNull(prefix);
Copy link
Copy Markdown
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
Copy Markdown
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