internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, this.nameAvt, Keywords.s_Name); this.name = PrecalculateAvt(ref this.nameAvt); this.nsUri = PrecalculateAvt(ref this.nsAvt); // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore if (this.nameAvt == null && this.nsAvt == null) { if (this.name != Keywords.s_Xmlns) { this.qname = CreateAttributeQName(this.name, this.nsUri, compiler.CloneScopeManager()); } } else { this.manager = compiler.CloneScopeManager(); } if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } }
private PrefixQName qname; // When we not have AVTs at all we can do this. null otherwise. private static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager) { // if name == "xmlns" we don't need to generate this attribute. // to avoid i'ts generation we can return false and not add AtributeCation to it's parent container action // for now not creating this.qname will do the trick at execution time if (name == Keywords.s_Xmlns) return null; if (nsUri == Keywords.s_XmlnsNamespace) { throw new XsltException(Res.Xslt_ReservedNS, nsUri); } PrefixQName qname = new PrefixQName(); qname.SetQName(name); qname.Namespace = nsUri != null ? nsUri : manager.ResolveXPathNamespace(qname.Prefix); if(qname.Prefix.StartsWith("xml")) { if( qname.Prefix.Length == 3 && qname.Namespace == Keywords.s_XmlNamespace && (qname.Name == "lang" || qname.Name == "space") ) { // preserve prefix for xml:lang and xml:space } else if (qname.Prefix == Keywords.s_Xmlns && nsUri == null) { // if NS wasn't specified we have to use prefix to find it and this is imposible for 'xmlns' throw new XsltException(Res.Xslt_InvalidPrefix, qname.Prefix); } else { qname.ClearPrefix(); } } return qname; }
// // Constructor // internal NavigatorInput(XPathNavigator navigator, string baseUri, InputScope rootScope) { if (navigator == null) { throw new ArgumentNullException("navigator"); } if (baseUri == null) { throw new ArgumentNullException("baseUri"); } Debug.Assert(navigator.NameTable != null); _Next = null; _Href = baseUri; _Atoms = new Keywords(navigator.NameTable); _Atoms.LookupKeywords(); _Navigator = navigator; _Manager = new InputScopeManager(_Navigator, rootScope); _PositionInfo = PositionInfo.GetPositionInfo(_Navigator); /*BeginReading:*/ AssertInput(); if (NodeType == XPathNodeType.Root) { _Navigator.MoveToFirstChild(); } }
internal InputScopeManager Clone() { InputScopeManager manager = new InputScopeManager(this.navigator, null); manager.scopeStack = this.scopeStack; manager.defaultNS = this.defaultNS; return(manager); }
internal void PushInputDocument(NavigatorInput newInput, string inputUri) { Debug.Assert(newInput != null); Debug.WriteLine("Pushing document \"" + inputUri + "\""); AddDocumentURI(inputUri); newInput.Next = this.input; this.input = newInput; this.atoms = this.input.Atoms; this.scopeManager = this.input.InputScopeManager; }
private PrefixQName qname; // When we not have AVTs at all we can do this. null otherwise. private static PrefixQName CreateAttributeQName(string name, string nsUri, InputScopeManager manager) { // if name == "xmlns" we don't need to generate this attribute. // to avoid i'ts generation we can return false and not add AtributeCation to it's parent container action // for now not creating this.qname will do the trick at execution time if (name == Keywords.s_Xmlns) { return(null); } if (nsUri == Keywords.s_XmlnsNamespace) { throw new XsltException(Res.Xslt_ReservedNS, nsUri); } PrefixQName qname = new PrefixQName(); qname.SetQName(name); qname.Namespace = nsUri != null ? nsUri : manager.ResolveXPathNamespace(qname.Prefix); if (qname.Prefix.StartsWith("xml")) { if (qname.Prefix.Length == 3) // prefix == "xml" { if (qname.Namespace == Keywords.s_XmlNamespace && (qname.Name == "lang" || qname.Name == "space")) { // preserve prefix for xml:lang and xml:space } else { qname.ClearPrefix(); } } else if (qname.Prefix == Keywords.s_Xmlns) { if (qname.Namespace == Keywords.s_XmlnsNamespace) { // if NS wasn't specified we have to use prefix to find it and this is imposible for 'xmlns' throw new XsltException(Res.Xslt_InvalidPrefix, qname.Prefix); } else { qname.ClearPrefix(); } } } return(qname); }
private static PrefixQName CreateElementQName(string name, string nsUri, InputScopeManager manager) { if (nsUri == Keywords.s_XmlnsNamespace) { throw new XsltException(Res.Xslt_ReservedNS, nsUri); } PrefixQName qname = new PrefixQName(); qname.SetQName(name); if (nsUri == null) { qname.Namespace = manager.ResolveXmlNamespace(qname.Prefix); } else { qname.Namespace = nsUri; } return qname; }
private XmlDataType ParseDataType(string value, InputScopeManager manager) { if(value == null) { // Avt is not constant, or attribute wasn't defined return XmlDataType.Text; } if (value == Keywords.s_Text) { return XmlDataType.Text; } if (value == Keywords.s_Number) { return XmlDataType.Number; } String prefix, localname; PrefixQName.ParseQualifiedName(value, out prefix, out localname); manager.ResolveXmlNamespace(prefix); if (prefix == String.Empty && ! this.forwardCompatibility) { throw XsltException.InvalidAttrValue(Keywords.s_DataType, value); } return XmlDataType.Text; }
private static PrefixQName CreateElementQName(string name, string nsUri, InputScopeManager manager) { if (nsUri == Keywords.s_XmlnsNamespace) { throw new XsltException(Res.Xslt_ReservedNS, nsUri); } PrefixQName qname = new PrefixQName(); qname.SetQName(name); if (nsUri == null) { qname.Namespace = manager.ResolveXmlNamespace(qname.Prefix); } else { qname.Namespace = nsUri; } return(qname); }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckEmpty(compiler); if (selectKey == Compiler.InvalidQueryKey) { selectKey = compiler.AddQuery(Compiler.SelfQuery); } this.forwardCompatibility = compiler.ForwardCompatibility; this.manager = compiler.CloneScopeManager(); this.lang = ParseLang(PrecalculateAvt(ref this.langAvt)); this.dataType = ParseDataType(PrecalculateAvt(ref this.dataTypeAvt), manager); this.order = ParseOrder(PrecalculateAvt(ref this.orderAvt)); this.caseOrder = ParseCaseOrder(PrecalculateAvt(ref this.caseOrderAvt)); if (this.langAvt == null && this.dataTypeAvt == null && this.orderAvt == null && this.caseOrderAvt == null) { this.sort = new Sort(this.selectKey, this.lang, this.dataType, this.order, this.caseOrder); } }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckRequiredAttribute(compiler, this.nameAvt, Keywords.s_Name); this.name = PrecalculateAvt(ref this.nameAvt); this.nsUri = PrecalculateAvt(ref this.nsAvt ); // if both name and ns are not AVT we can calculate qname at compile time and will not need namespace manager anymore if (this.nameAvt == null && this.nsAvt == null) { if(this.name != Keywords.s_Xmlns) { this.qname = CreateAttributeQName(this.name, this.nsUri, compiler.CloneScopeManager()); } } else { this.manager = compiler.CloneScopeManager(); } if (compiler.Recurse()) { CompileTemplate(compiler); compiler.ToParent(); } }
private XmlDataType ParseDataType(string value, InputScopeManager manager) { if (value == null) // Avt is not constant, or attribute wasn't defined { return(XmlDataType.Text); } if (value == Keywords.s_Text) { return(XmlDataType.Text); } if (value == Keywords.s_Number) { return(XmlDataType.Number); } String prefix, localname; PrefixQName.ParseQualifiedName(value, out prefix, out localname); manager.ResolveXmlNamespace(prefix); if (prefix == String.Empty && !this.forwardCompatibility) { throw XsltException.InvalidAttrValue(Keywords.s_DataType, value); } return(XmlDataType.Text); }
internal void PopInputDocument() { Debug.Assert(this.input != null); Debug.Assert(this.input.Atoms == this.atoms); NavigatorInput lastInput = this.input; this.input = lastInput.Next; lastInput.Next = null; if (this.input != null) { this.atoms = this.input.Atoms; this.scopeManager = this.input.InputScopeManager; } else { this.atoms = null; this.scopeManager = null; } RemoveDocumentURI(lastInput.Href); lastInput.Close(); }
internal XsltCompileContext(InputScopeManager manager, Processor processor) { this.manager = manager; this.processor = processor; //InitFunctions(); }
internal InputScopeManager Clone() { InputScopeManager manager = new InputScopeManager(this.navigator, null); manager.scopeStack = this.scopeStack; manager.defaultNS = this.defaultNS; return manager; }
internal override void Compile(Compiler compiler) { CompileAttributes(compiler); CheckEmpty(compiler); if (selectKey == Compiler.InvalidQueryKey) { selectKey = compiler.AddQuery(Compiler.SelfQuery); } this.forwardCompatibility = compiler.ForwardCompatibility; this.manager = compiler.CloneScopeManager(); this.lang = ParseLang( PrecalculateAvt(ref this.langAvt )); this.dataType = ParseDataType( PrecalculateAvt(ref this.dataTypeAvt ), manager); this.order = ParseOrder( PrecalculateAvt(ref this.orderAvt )); this.caseOrder = ParseCaseOrder(PrecalculateAvt(ref this.caseOrderAvt)); if(this.langAvt == null && this.dataTypeAvt == null && this.orderAvt == null && this.caseOrderAvt == null) { this.sort = new Sort(this.selectKey, this.lang, this.dataType, this.order, this.caseOrder); } }
internal TheQuery( CompiledXpathExpr compiledQuery, InputScopeManager manager) { _CompiledQuery = compiledQuery; _ScopeManager = manager.Clone(); }
internal TheQuery(CompiledXpathExpr compiledQuery, InputScopeManager manager) { _CompiledQuery = compiledQuery; _ScopeManager = manager.Clone(); }