Skip to content

Commit

Permalink
Extend xmlname pattern to allow namespace prefixes
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Oct 29, 2019
1 parent 1e3c245 commit 4241042
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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-]*)?$")
string xmlName

/// Adds an xmlns namespace definition URI to an XML element.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,17 @@ public void loadsTraitWithString() {
assertThat(xmlNameTrait.getValue(), equalTo("Text"));
assertThat(xmlNameTrait.toNode(), equalTo(node));
}

@Test
public void loadsWithColonInValue() {
Node node = Node.from("xsi:type");
TraitFactory provider = TraitFactory.createServiceFactory();
Optional<Trait> trait = provider.createTrait(ShapeId.from("smithy.api#xmlName"), ShapeId.from("ns.qux#foo"), node);

assertTrue(trait.isPresent());
assertThat(trait.get(), instanceOf(XmlNameTrait.class));
XmlNameTrait xmlNameTrait = (XmlNameTrait) trait.get();
assertThat(xmlNameTrait.getValue(), equalTo("xsi:type"));
assertThat(xmlNameTrait.toNode(), equalTo(node));
}
}

0 comments on commit 4241042

Please sign in to comment.