1 28 29 package com.caucho.xsl.java; 30 31 import com.caucho.java.JavaWriter; 32 import com.caucho.xml.QName; 33 import com.caucho.xsl.XslParseException; 34 35 38 public class XslNamespaceAlias extends XslNode implements XslTopNode { 39 private String _stylesheetPrefix; 40 private String _resultPrefix; 41 42 45 public String getTagName() 46 { 47 return "xsl:namespace-alias"; 48 } 49 50 53 public void addAttribute(QName name, String value) 54 throws XslParseException 55 { 56 if (name.getName().equals("stylesheet-prefix")) { 57 _stylesheetPrefix = value; 58 } 59 else if (name.getName().equals("result-prefix")) { 60 _resultPrefix = value; 61 } 62 else 63 super.addAttribute(name, value); 64 } 65 66 69 public void endAttributes() 70 throws XslParseException 71 { 72 if (_stylesheetPrefix == null) 73 throw error(L.l("'stylesheet-prefix' is a required attribute of <xsl:namespace-alias>")); 74 if (_resultPrefix == null) 75 throw error(L.l("'result-prefix' is a required attribute of <xsl:namespace-alias>")); 76 } 77 78 81 public void endElement() 82 throws Exception 83 { 84 String stylesheetNs = getNamespace(_stylesheetPrefix); 85 86 if (_stylesheetPrefix.equals("#default")) 87 stylesheetNs = ""; 88 else if (stylesheetNs.equals("")) 89 throw error(L.l("'{0}' is not a valid namespace prefix", 90 _stylesheetPrefix)); 91 92 String resultNs = getNamespace(_resultPrefix); 93 if (_resultPrefix.equals("#default")) { 94 _resultPrefix = ""; 95 resultNs = ""; 96 } 97 else if (resultNs == null) 98 throw error(L.l("'{0}' is not a valid namespace prefix", 99 _resultPrefix)); 100 101 String result[] = new String [] { _resultPrefix, resultNs }; 102 103 _gen.addNamespaceAlias(stylesheetNs, result); 104 } 105 106 111 public void generate(JavaWriter out) 112 throws Exception 113 { 114 } 115 } 116 | Popular Tags |