1 package net.sf.saxon.style; 2 import net.sf.saxon.expr.Expression; 3 import net.sf.saxon.instruct.Executable; 4 import net.sf.saxon.om.AttributeCollection; 5 import net.sf.saxon.om.NamePool; 6 import net.sf.saxon.om.NamespaceException; 7 import net.sf.saxon.trans.XPathException; 8 9 10 13 14 public class XSLNamespaceAlias extends StyleElement { 15 16 private short stylesheetURICode; 17 private int resultNamespaceCode; 18 19 public void prepareAttributes() throws XPathException { 20 21 String stylesheetPrefix=null; 22 String resultPrefix=null; 23 24 AttributeCollection atts = getAttributeList(); 25 26 for (int a=0; a<atts.getLength(); a++) { 27 int nc = atts.getNameCode(a); 28 String f = getNamePool().getClarkName(nc); 29 if (f==StandardNames.STYLESHEET_PREFIX) { 30 stylesheetPrefix = atts.getValue(a).trim(); 31 } else if (f==StandardNames.RESULT_PREFIX) { 32 resultPrefix = atts.getValue(a).trim(); 33 } else { 34 checkUnknownAttribute(nc); 35 } 36 } 37 if (stylesheetPrefix==null) { 38 reportAbsence("stylesheet-prefix"); 39 return; 40 } 41 if (stylesheetPrefix.equals("#default")) { 42 stylesheetPrefix=""; 43 } 44 if (resultPrefix==null) { 45 reportAbsence("result-prefix"); 46 return; 47 } 48 if (resultPrefix.equals("#default")) { 49 resultPrefix=""; 50 } 51 try { 52 String ssURI = getURIForPrefix(stylesheetPrefix, true); 53 if (ssURI == null) { 54 compileError("stylesheet-prefix " + stylesheetPrefix + " has not been declared", "XTSE0812"); 55 stylesheetURICode = 0; 58 resultNamespaceCode = 0; 59 return; 60 } 61 stylesheetURICode = getURICodeForPrefix(stylesheetPrefix); 62 NamePool pool = getNamePool(); 63 String resultURI = getURIForPrefix(resultPrefix, true); 64 if (resultURI == null) { 65 compileError("result-prefix " + resultPrefix + " has not been declared", "XTSE0812"); 66 stylesheetURICode = 0; 69 resultNamespaceCode = 0; 70 return; 71 } 72 resultNamespaceCode = pool.getNamespaceCode( 73 resultPrefix, 74 resultURI); 75 } catch (NamespaceException err) { 76 compileError(err.getMessage()); 77 } 78 } 79 80 public void validate() throws XPathException { 81 checkTopLevel(null); 82 } 83 84 public Expression compile(Executable exec) throws XPathException { 85 return null; 86 } 87 88 public short getStylesheetURICode() { 89 return stylesheetURICode; 90 } 91 92 public int getResultNamespaceCode() { 93 return resultNamespaceCode; 94 } 95 96 } 97 98 | Popular Tags |