@Test public void shouldReturnQNameWithLocalPartAndPrefixAndNamespace() { QName result = extractor.getName(PREFIX + SEPARATOR + LOCAL_PART, NAMESPACE); assertThat(result.getLocalPart(), is(LOCAL_PART)); assertThat(result.getNamespaceURI(), is(NAMESPACE)); assertThat(result.getPrefix(), is(PREFIX)); }
public QName getName(String name, String namespace) { String[] parts = name.split(":"); if (parts.length < 1 || parts.length > 2) { throw new RuntimeException("Variable name '" + name + "' is invalid"); } String namespacePrefix = null; String localPart = parts[parts.length - 1]; if (parts.length == 2) { namespacePrefix = parts[0]; } if (namespace != null && namespace.length() > 0) { if (namespacePrefix != null) { return new QName(namespace, localPart, namespacePrefix); } else { return new QName(namespace, localPart); } } if (namespacePrefix != null) { return new QName(DEFAULT_NS_PREFIX, localPart, namespacePrefix); } else { return new QName(localPart); } }
NameExtractor { public QName getName(String name, String namespace) { String[] parts = name.split(":"); if (parts.length < 1 || parts.length > 2) { throw new RuntimeException("Variable name '" + name + "' is invalid"); } String namespacePrefix = null; String localPart = parts[parts.length - 1]; if (parts.length == 2) { namespacePrefix = parts[0]; } if (namespace != null && namespace.length() > 0) { if (namespacePrefix != null) { return new QName(namespace, localPart, namespacePrefix); } else { return new QName(namespace, localPart); } } if (namespacePrefix != null) { return new QName(DEFAULT_NS_PREFIX, localPart, namespacePrefix); } else { return new QName(localPart); } } }
NameExtractor { public QName getName(String name, String namespace) { String[] parts = name.split(":"); if (parts.length < 1 || parts.length > 2) { throw new RuntimeException("Variable name '" + name + "' is invalid"); } String namespacePrefix = null; String localPart = parts[parts.length - 1]; if (parts.length == 2) { namespacePrefix = parts[0]; } if (namespace != null && namespace.length() > 0) { if (namespacePrefix != null) { return new QName(namespace, localPart, namespacePrefix); } else { return new QName(namespace, localPart); } } if (namespacePrefix != null) { return new QName(DEFAULT_NS_PREFIX, localPart, namespacePrefix); } else { return new QName(localPart); } }  }
NameExtractor { public QName getName(String name, String namespace) { String[] parts = name.split(":"); if (parts.length < 1 || parts.length > 2) { throw new RuntimeException("Variable name '" + name + "' is invalid"); } String namespacePrefix = null; String localPart = parts[parts.length - 1]; if (parts.length == 2) { namespacePrefix = parts[0]; } if (namespace != null && namespace.length() > 0) { if (namespacePrefix != null) { return new QName(namespace, localPart, namespacePrefix); } else { return new QName(namespace, localPart); } } if (namespacePrefix != null) { return new QName(DEFAULT_NS_PREFIX, localPart, namespacePrefix); } else { return new QName(localPart); } }  QName getName(String name, String namespace); }
NameExtractor { public QName getName(String name, String namespace) { String[] parts = name.split(":"); if (parts.length < 1 || parts.length > 2) { throw new RuntimeException("Variable name '" + name + "' is invalid"); } String namespacePrefix = null; String localPart = parts[parts.length - 1]; if (parts.length == 2) { namespacePrefix = parts[0]; } if (namespace != null && namespace.length() > 0) { if (namespacePrefix != null) { return new QName(namespace, localPart, namespacePrefix); } else { return new QName(namespace, localPart); } } if (namespacePrefix != null) { return new QName(DEFAULT_NS_PREFIX, localPart, namespacePrefix); } else { return new QName(localPart); } }  QName getName(String name, String namespace);  }