1 /* Copyright 2004 The Apache Software Foundation 2 * 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 package org.apache.xmlbeans.impl.inst2xsd; 16 17 import org.apache.xmlbeans.impl.inst2xsd.util.Element; 18 import org.apache.xmlbeans.impl.inst2xsd.util.TypeSystemHolder; 19 20 /** 21 * @author Cezar Andrei ( cezar.andrei at bea.com ) 22 * Date: Jul 26, 2004 23 */ 24 public class SalamiSliceStrategy 25 extends RussianDollStrategy 26 implements XsdGenStrategy 27 { 28 protected void checkIfElementReferenceIsNeeded(Element child, String parentNamespace, 29 TypeSystemHolder typeSystemHolder, Inst2XsdOptions options) 30 { 31 // always add element references 32 Element referencedElem = new Element(); 33 referencedElem.setGlobal(true); 34 referencedElem.setName(child.getName()); 35 referencedElem.setType(child.getType()); 36 37 if (child.isNillable()) 38 { 39 referencedElem.setNillable(true); 40 child.setNillable(false); 41 } 42 43 referencedElem = addGlobalElement(referencedElem, typeSystemHolder, options); 44 45 child.setRef(referencedElem); // clears child's type 46 } 47 }