blob: b13ba6bd424dbd44f8db5920f0ed1a539d7f2618 [file] [log] [blame]
nitind958d79a2004-11-23 19:23:00 +00001/*******************************************************************************
2 * Copyright (c) 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.wst.html.core.contentmodel;
12
13
14
15import java.util.Arrays;
16
17import org.eclipse.wst.common.contentmodel.CMElementDeclaration;
18import org.eclipse.wst.common.contentmodel.CMGroup;
19import org.eclipse.wst.common.contentmodel.CMNode;
20import org.eclipse.wst.html.core.HTML40Namespace;
21
22/**
23 * Complex type definition for <code>HTML</code>.<br>
24 * Content Model:
25 * HEAD, (FRAMESET|BODY)<br>
26 */
27final class CtdHtml extends ComplexTypeDefinition {
28
29 /**
30 */
31 public CtdHtml(ElementCollection elementCollection) {
32 super(elementCollection);
33 primaryCandidateName = HTML40Namespace.ElementName.HEAD;
34 }
35
36 /**
37 * (%html.content;).
38 * %html.content; is HEAD, (FRAMESET | BODY).
39 * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition
40 */
41 protected void createContent() {
42 if (content != null)
43 return; // already created.
44 if (collection == null)
45 return;
46
47 // ( )
48 content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1);
49 if (content == null)
50 return;
51
52 // HEAD
53 CMNode edec = collection.getNamedItem(HTML40Namespace.ElementName.HEAD);
54 if (edec != null)
55 content.appendChild(edec);
56
57 // ( | )
58 CMGroupImpl group = new CMGroupImpl(CMGroup.CHOICE, 1, 1);
59 content.appendChild(group);
60
61 // FRAMESET, BODY
62 String[] names = {HTML40Namespace.ElementName.FRAMESET, HTML40Namespace.ElementName.BODY};
63 collection.getDeclarations(group, Arrays.asList(names).iterator());
64 }
65
66 /**
67 * Element content.
68 * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition
69 */
70 public int getContentType() {
71 return CMElementDeclaration.ELEMENT;
72 }
73
74 /**
75 * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition
76 */
77 public String getTypeName() {
78 return ComplexTypeDefinitionFactory.CTYPE_HTML;
79 }
80}