001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /* $Id: AbstractListItemPart.java 554094 2007-07-07 00:04:25Z adelmelle $ */
019:
020: package org.apache.fop.fo.flow;
021:
022: import org.xml.sax.Locator;
023:
024: import org.apache.fop.apps.FOPException;
025: import org.apache.fop.fo.FONode;
026: import org.apache.fop.fo.FObj;
027: import org.apache.fop.fo.PropertyList;
028: import org.apache.fop.fo.ValidationException;
029: import org.apache.fop.fo.properties.CommonAccessibility;
030: import org.apache.fop.fo.properties.KeepProperty;
031:
032: /**
033: * Class modelling the fo:list-item-body object.
034: */
035: public abstract class AbstractListItemPart extends FObj {
036: // The value of properties relevant for fo:list-item-label and fo:list-item-body.
037: private KeepProperty keepTogether;
038: // Valid properties, commented out for performance:
039: // private CommonAccessibility commonAccessibility;
040: // End of property values
041:
042: /** used for FO validation */
043: private boolean blockItemFound = false;
044:
045: /**
046: * @param parent FONode that is the parent of this object
047: */
048: public AbstractListItemPart(FONode parent) {
049: super (parent);
050: }
051:
052: /**
053: * @see org.apache.fop.fo.FObj#bind(PropertyList)
054: */
055: public void bind(PropertyList pList) throws FOPException {
056: super .bind(pList);
057: keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep();
058: }
059:
060: /**
061: * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
062: * XSL Content Model: marker* (%block;)+
063: */
064: protected void validateChildNode(Locator loc, String nsURI,
065: String localName) throws ValidationException {
066: if (FO_URI.equals(nsURI) && localName.equals("marker")) {
067: if (blockItemFound) {
068: nodesOutOfOrderError(loc, "fo:marker", "(%block;)");
069: }
070: } else if (!isBlockItem(nsURI, localName)) {
071: invalidChildError(loc, nsURI, localName);
072: } else {
073: blockItemFound = true;
074: }
075: }
076:
077: /**
078: * @see org.apache.fop.fo.FONode#endOfNode
079: */
080: protected void endOfNode() throws FOPException {
081: if (!this .blockItemFound) {
082: String contentModel = "marker* (%block;)+";
083: if (getUserAgent().validateStrictly()) {
084: missingChildElementError(contentModel);
085: } else {
086: StringBuffer message = new StringBuffer(
087: errorText(getLocator()));
088: message.append(getName()).append(
089: " is missing child elements. ").append(
090: "Required Content Model: ")
091: .append(contentModel);
092: log.warn(message.toString());
093: }
094: }
095: }
096:
097: /** @return the "keep-together" property. */
098: public KeepProperty getKeepTogether() {
099: return keepTogether;
100: }
101: }
|