@Test public void shouldParseAttributeTest() { AttributeTest result = parser.parseAttributeTest(tokenize("attribute(foo)")); assertThat(result, is(notNullValue())); assertThat(result.getAttributeName(), is(nameTest("foo"))); assertThat(result.getTypeName(), is(wildcard())); result = parser.parseAttributeTest(tokenize("attribute(foo:bar)")); assertThat(result, is(notNullValue())); assertThat(result.getAttributeName(), is(nameTest("foo", "bar"))); assertThat(result.getTypeName(), is(wildcard())); result = parser.parseAttributeTest(tokenize("attribute(foo:bar,baz)")); assertThat(result, is(notNullValue())); assertThat(result.getAttributeName(), is(nameTest("foo", "bar"))); assertThat(result.getTypeName(), is(nameTest("baz"))); result = parser.parseAttributeTest(tokenize("attribute(foo:bar,baz:bar)")); assertThat(result, is(notNullValue())); assertThat(result.getAttributeName(), is(nameTest("foo", "bar"))); assertThat(result.getTypeName(), is(nameTest("baz", "bar"))); result = parser.parseAttributeTest(tokenize("attribute(*,baz:bar)")); assertThat(result, is(notNullValue())); assertThat(result.getAttributeName(), is(wildcard())); assertThat(result.getTypeName(), is(nameTest("baz", "bar"))); result = parser.parseAttributeTest(tokenize("attribute(foo:bar,*)")); assertThat(result, is(notNullValue())); assertThat(result.getAttributeName(), is(nameTest("foo", "bar"))); assertThat(result.getTypeName(), is(wildcard())); }
protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath ); }
XPathParser { protected AttributeTest parseAttributeTest( TokenStream tokens ) { if (tokens.canConsume("attribute", "(")) { if (tokens.canConsume(")") || tokens.canConsume("*", ")")) { return new AttributeTest(new NameTest(null, null), new NameTest(null, null)); } AttributeTest result = null; NameTest attributeName = parseNameTest(tokens); if (tokens.canConsume(",")) { NameTest typeName = parseNameTest(tokens); result = new AttributeTest(attributeName, typeName); } else { result = new AttributeTest(attributeName, new NameTest(null, null)); } tokens.consume(")"); return result; } return null; } XPathParser( TypeSystem context ); Component parseXPath( String xpath );  }