nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 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 | *******************************************************************************/ |
david_williams | 5677702 | 2005-04-11 06:21:55 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.html.core.internal.contentmodel; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 12 | |
| 13 | |
| 14 | |
| 15 | import java.util.Arrays; |
| 16 | |
david_williams | 4ad020f | 2005-04-18 08:00:30 +0000 | [diff] [blame] | 17 | import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace; |
david_williams | c06c86f | 2005-03-18 18:23:41 +0000 | [diff] [blame] | 18 | import org.eclipse.wst.xml.core.internal.contentmodel.CMContent; |
| 19 | import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup; |
| 20 | import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * MENU/DIR. |
| 24 | */ |
| 25 | final class HedMENU extends HedListItemContainer { |
| 26 | |
| 27 | /** |
| 28 | */ |
| 29 | public HedMENU(String elementName, ElementCollection collection) { |
| 30 | super(elementName, collection); |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * MENU/DIR. |
| 35 | * (compact (compact) #IMPLIED) |
| 36 | */ |
| 37 | protected void createAttributeDeclarations() { |
| 38 | if (attributes != null) |
| 39 | return; // already created. |
| 40 | if (attributeCollection == null) |
| 41 | return; // fatal |
| 42 | |
| 43 | attributes = new CMNamedNodeMapImpl(); |
| 44 | |
| 45 | // %attrs; |
| 46 | attributeCollection.getAttrs(attributes); |
| 47 | |
| 48 | String[] names = {HTML40Namespace.ATTR_NAME_COMPACT}; |
| 49 | attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Exclusion. |
| 54 | * <code>MENU/DIR</code> has the exclusion. |
| 55 | * It is <code>%block;</code>. |
| 56 | * %block; is: |
| 57 | * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | |
| 58 | * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | |
| 59 | * TABLE | FIELDSET | ADDRESS. |
| 60 | * %heading; is: H1 | H2 | H3 | H4 | H5 | H6. |
| 61 | * %list; is : UL | OL | DIR | MENU. |
| 62 | * %preformatted; is PRE. |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 63 | */ |
| 64 | public CMContent getExclusion() { |
| 65 | if (exclusion != null) |
| 66 | return exclusion; // already created. |
| 67 | if (elementCollection == null) |
| 68 | return null; |
| 69 | |
| 70 | // %block; |
| 71 | exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); |
| 72 | String[] names = {HTML40Namespace.ElementName.P, HTML40Namespace.ElementName.H1, HTML40Namespace.ElementName.H2, HTML40Namespace.ElementName.H3, HTML40Namespace.ElementName.H4, HTML40Namespace.ElementName.H5, HTML40Namespace.ElementName.H6, HTML40Namespace.ElementName.UL, HTML40Namespace.ElementName.OL, HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU, HTML40Namespace.ElementName.PRE, HTML40Namespace.ElementName.DL, HTML40Namespace.ElementName.DIV, HTML40Namespace.ElementName.CENTER, HTML40Namespace.ElementName.NOSCRIPT, HTML40Namespace.ElementName.NOFRAMES, HTML40Namespace.ElementName.BLOCKQUOTE, HTML40Namespace.ElementName.FORM, HTML40Namespace.ElementName.ISINDEX, HTML40Namespace.ElementName.HR, HTML40Namespace.ElementName.TABLE, HTML40Namespace.ElementName.FIELDSET, HTML40Namespace.ElementName.ADDRESS}; |
| 73 | elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); |
| 74 | return exclusion; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | */ |
| 79 | public CMNamedNodeMap getProhibitedAncestors() { |
| 80 | if (prohibitedAncestors != null) |
| 81 | return prohibitedAncestors; |
| 82 | |
| 83 | String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.ElementName.MENU}; |
| 84 | prohibitedAncestors = elementCollection.getDeclarations(names); |
| 85 | |
| 86 | return prohibitedAncestors; |
| 87 | } |
| 88 | } |