1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.htmlunit.html;
16
17 import java.util.Map;
18
19 import org.htmlunit.SgmlPage;
20 import org.xml.sax.Attributes;
21
22
23
24
25
26
27
28
29
30
31
32 public final class UnknownElementFactory implements ElementFactory {
33
34
35 public static final UnknownElementFactory INSTANCE = new UnknownElementFactory();
36
37
38 private UnknownElementFactory() {
39
40 }
41
42
43
44
45 @Override
46 public HtmlElement createElement(final SgmlPage page, final String tagName, final Attributes attributes) {
47 if (page != null && page.isHtmlPage() && tagName.indexOf(':') != -1) {
48 final HtmlPage htmlPage = (HtmlPage) page;
49 final String prefix = tagName.substring(0, tagName.indexOf(':'));
50 final String namespace = htmlPage.getNamespaces().get(prefix);
51 return createElementNS(page, namespace, tagName, attributes);
52 }
53
54 return createElementNS(page, null, tagName, attributes);
55 }
56
57
58
59
60 @Override
61 public HtmlElement createElementNS(final SgmlPage page, final String namespaceURI,
62 final String qualifiedName, final Attributes attributes) {
63 final Map<String, DomAttr> attributeMap = DefaultElementFactory.toMap(page, attributes);
64 return new HtmlUnknownElement(page, qualifiedName, attributeMap);
65 }
66 }