1 package net.sf.saxon.style; 2 import net.sf.saxon.expr.Expression; 3 import net.sf.saxon.expr.ExpressionTool; 4 import net.sf.saxon.instruct.Executable; 5 import net.sf.saxon.instruct.Namespace; 6 import net.sf.saxon.om.AttributeCollection; 7 import net.sf.saxon.value.StringValue; 8 import net.sf.saxon.trans.XPathException; 9 10 import javax.xml.transform.TransformerConfigurationException ; 11 12 15 16 public class XSLNamespace extends XSLStringConstructor { 17 18 Expression name; 19 20 public void prepareAttributes() throws XPathException { 21 22 String nameAtt = null; 23 String selectAtt = null; 24 25 AttributeCollection atts = getAttributeList(); 26 27 for (int a=0; a<atts.getLength(); a++) { 28 int nc = atts.getNameCode(a); 29 String f = getNamePool().getClarkName(nc); 30 if (f==StandardNames.NAME) { 31 nameAtt = atts.getValue(a).trim(); 32 } else if (f==StandardNames.SELECT) { 33 selectAtt = atts.getValue(a).trim(); 34 } else { 35 checkUnknownAttribute(nc); 36 } 37 } 38 if (nameAtt==null) { 39 reportAbsence("name"); 40 } else { 41 name = makeAttributeValueTemplate(nameAtt); 42 } 43 44 if (selectAtt!=null) { 45 select = makeExpression(selectAtt); 46 } 47 48 } 49 50 public void validate() throws XPathException { 51 checkWithinTemplate(); 52 name = typeCheck("name", name); 53 select = typeCheck("select", select); 54 super.validate(); 55 } 56 57 public Expression compile(Executable exec) throws XPathException { 58 Namespace inst = new Namespace(name); 59 compileContent(exec, inst, StringValue.SINGLE_SPACE); 60 ExpressionTool.makeParentReferences(inst); 61 return inst; 62 } 63 64 } 65 66 | Popular Tags |