本文整理汇总了C#中System.Xml.Xsl.Compiler.PopScope方法的典型用法代码示例。如果您正苦于以下问题:C# Compiler.PopScope方法的具体用法?C# Compiler.PopScope怎么用?C# Compiler.PopScope使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.Xsl.Compiler
的用法示例。
在下文中一共展示了Compiler.PopScope方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CompileContent
private void CompileContent(Compiler compiler) {
NavigatorInput input = compiler.Input;
if (compiler.Recurse()) {
do {
Debug.Trace(input);
switch(input.NodeType) {
case XPathNodeType.Element:
compiler.PushNamespaceScope();
string nspace = input.NamespaceURI;
string name = input.LocalName;
if (Keywords.Equals(nspace, input.Atoms.XsltNamespace) && Keywords.Equals(name, input.Atoms.WithParam)) {
WithParamAction par = compiler.CreateWithParamAction();
CheckDuplicateParams(par.Name);
AddAction(par);
}
else {
throw XsltException.UnexpectedKeyword(compiler);
}
compiler.PopScope();
break;
case XPathNodeType.Comment:
case XPathNodeType.ProcessingInstruction:
case XPathNodeType.Whitespace:
case XPathNodeType.SignificantWhitespace:
break;
default:
throw new XsltException(Res.Xslt_InvalidContents, Keywords.s_CallTemplate);
}
} while(compiler.Advance());
compiler.ToParent();
}
}
示例2: CompileConditions
private void CompileConditions(Compiler compiler) {
NavigatorInput input = compiler.Input;
bool when = false;
bool otherwise = false;
do {
Debug.Trace(input);
switch (input.NodeType) {
case XPathNodeType.Element:
compiler.PushNamespaceScope();
string nspace = input.NamespaceURI;
string name = input.LocalName;
if (Keywords.Equals(nspace, input.Atoms.XsltNamespace)) {
IfAction action = null;
if (Keywords.Equals(name, input.Atoms.When) && ! otherwise) {
action = compiler.CreateIfAction(IfAction.ConditionType.ConditionWhen);
when = true;
}
else if (Keywords.Equals(name, input.Atoms.Otherwise) && ! otherwise) {
action = compiler.CreateIfAction(IfAction.ConditionType.ConditionOtherwise);
otherwise = true;
}
else {
throw XsltException.UnexpectedKeyword(compiler);
}
AddAction(action);
}
else {
throw XsltException.UnexpectedKeyword(compiler);
}
compiler.PopScope();
break;
case XPathNodeType.Comment:
case XPathNodeType.ProcessingInstruction:
case XPathNodeType.Whitespace:
case XPathNodeType.SignificantWhitespace:
break;
default:
throw new XsltException(Res.Xslt_InvalidContents, Keywords.s_Choose);
}
}
while (compiler.Advance());
if (! when) {
throw new XsltException(Res.Xslt_NoWhen);
}
}
示例3: CompileParameters
protected void CompileParameters(Compiler compiler) {
NavigatorInput input = compiler.Input;
do {
switch(input.NodeType) {
case XPathNodeType.Element:
if (Keywords.Equals(input.NamespaceURI, input.Atoms.XsltNamespace) &&
Keywords.Equals(input.LocalName, input.Atoms.Param)) {
compiler.PushNamespaceScope();
AddAction(compiler.CreateVariableAction(VariableType.LocalParameter));
compiler.PopScope();
continue;
}
else {
return;
}
case XPathNodeType.Text:
return;
case XPathNodeType.SignificantWhitespace:
this.AddEvent(compiler.CreateTextEvent());
continue;
default :
continue;
}
}
while (input.Advance());
}
示例4: Compile
//.........这里部分代码省略.........
content.Add (new XslAttribute (c));
break;
case "call-template":
content.Add (new XslCallTemplate (c));
break;
case "choose":
content.Add (new XslChoose (c));
break;
case "comment":
if (ParentType == XPathNodeType.All
|| ParentType == XPathNodeType.Element)
content.Add (new XslComment (c));
break;
case "copy":
content.Add (new XslCopy (c));
break;
case "copy-of":
content.Add (new XslCopyOf (c));
break;
case "element":
if (ParentType == XPathNodeType.All
|| ParentType == XPathNodeType.Element)
content.Add (new XslElement (c));
break;
case "fallback":
break;
case "for-each":
content.Add (new XslForEach (c));
break;
case "if":
content.Add (new XslIf (c));
break;
case "message":
content.Add (new XslMessage(c));
break;
case "number":
content.Add (new XslNumber(c));
break;
case "processing-instruction":
if (ParentType == XPathNodeType.All
|| ParentType == XPathNodeType.Element)
content.Add (new XslProcessingInstruction(c));
break;
case "text":
content.Add (new XslText(c, false));
break;
case "value-of":
content.Add (new XslValueOf(c));
break;
case "variable":
content.Add (new XslLocalVariable (c));
break;
case "sort":
if (xslForEach)
break;
throw new XsltCompileException ("'sort' element is not allowed here as a templete content", null, n);
default:
// TODO: handle fallback, like we should
// throw new XsltCompileException ("Did not recognize element " + n.Name, null, n);
content.Add (new XslNotSupportedOperation (c));
break;
}
break;
default:
if (!c.IsExtensionNamespace (n.NamespaceURI))
content.Add (new XslLiteralElement(c));
else {
if (n.MoveToFirstChild ()) {
do {
if (n.NamespaceURI == XsltNamespace && n.LocalName == "fallback")
content.Add (new XslFallback (c));
} while (n.MoveToNext ());
n.MoveToParent ();
}
}
break;
}
break;
case XPathNodeType.SignificantWhitespace:
content.Add (new XslText(c, true));
break;
case XPathNodeType.Text:
content.Add (new XslText(c, false));
break;
default:
break;
}
Debug.ExitNavigator (c);
} while (c.Input.MoveToNext ());
if (hasStack) {
stackSize = c.PopScope ().VariableHighTide;
hasStack = stackSize > 0;
} else
c.PopScope ();
}
示例5: CompileOnceTemplate
protected void CompileOnceTemplate(Compiler compiler) {
NavigatorInput input = compiler.Input;
Debug.Trace(input);
if (input.NodeType == XPathNodeType.Element) {
string nspace = input.NamespaceURI;
if (Keywords.Equals(nspace, input.Atoms.XsltNamespace)) {
compiler.PushNamespaceScope();
CompileInstruction(compiler);
compiler.PopScope();
}
else {
compiler.PushLiteralScope();
compiler.InsertExtensionNamespace();
if (compiler.IsExtensionNamespace(nspace)) {
AddAction(compiler.CreateNewInstructionAction());
}
else {
CompileLiteral(compiler);
}
compiler.PopScope();
}
}
else {
CompileLiteral(compiler);
}
}
示例6: CompileTopLevelElements
protected void CompileTopLevelElements(Compiler compiler) {
// Navigator positioned at parent root, need to move to child and then back
if (compiler.Recurse() == false) {
Debug.WriteLine("Nothing to compile, exiting");
return;
}
NavigatorInput input = compiler.Input;
bool notFirstElement = false;
do {
Debug.Trace(input);
switch (input.NodeType) {
case XPathNodeType.Element:
string name = input.LocalName;
string nspace = input.NamespaceURI;
if (Keywords.Equals(nspace, input.Atoms.XsltNamespace)) {
if (Keywords.Equals(name, input.Atoms.Import)) {
if (notFirstElement) {
throw new XsltException(Res.Xslt_NotFirstImport);
}
// We should compile imports in reverse order after all toplevel elements.
// remember it now and return to it in CompileImpoorts();
compiler.CompiledStylesheet.Imports.Add(compiler.GetSingleAttribute(compiler.Input.Atoms.Href));
}
else if (Keywords.Equals(name, input.Atoms.Include)) {
notFirstElement = true;
CompileInclude(compiler);
}
else {
notFirstElement = true;
compiler.PushNamespaceScope();
if (Keywords.Equals(name, input.Atoms.StripSpace)) {
CompileSpace(compiler, false);
}
else if (Keywords.Equals(name, input.Atoms.PreserveSpace)) {
CompileSpace(compiler, true);
}
else if (Keywords.Equals(name, input.Atoms.Output)) {
CompileOutput(compiler);
}
else if (Keywords.Equals(name, input.Atoms.Key)) {
CompileKey(compiler);
}
else if (Keywords.Equals(name, input.Atoms.DecimalFormat)) {
CompileDecimalFormat(compiler);
}
else if (Keywords.Equals(name, input.Atoms.NamespaceAlias)) {
CompileNamespaceAlias(compiler);
}
else if (Keywords.Equals(name, input.Atoms.AttributeSet)) {
compiler.AddAttributeSet(compiler.CreateAttributeSetAction());
}
else if (Keywords.Equals(name, input.Atoms.Variable)) {
VariableAction action = compiler.CreateVariableAction(VariableType.GlobalVariable);
if (action != null) {
AddAction(action);
}
}
else if (Keywords.Equals(name, input.Atoms.Param)) {
VariableAction action = compiler.CreateVariableAction(VariableType.GlobalParameter);
if (action != null) {
AddAction(action);
}
}
else if (Keywords.Equals(name, input.Atoms.Template)) {
compiler.AddTemplate(compiler.CreateTemplateAction());
}
else {
if (!compiler.ForwardCompatibility) {
throw XsltException.UnexpectedKeyword(compiler);
}
}
compiler.PopScope();
}
}
else if (nspace == input.Atoms.MsXsltNamespace && name == input.Atoms.Script) {
AddScript(compiler);
}
else {
if (Keywords.Equals(nspace, input.Atoms.Empty)) {
throw new XsltException(Res.Xslt_NullNsAtTopLevel, input.Name);
}
// Ignoring non-recognized namespace per XSLT spec 2.2
}
break;
case XPathNodeType.ProcessingInstruction:
case XPathNodeType.Comment:
case XPathNodeType.Whitespace:
case XPathNodeType.SignificantWhitespace:
break;
default:
throw new XsltException(Res.Xslt_InvalidContents, "xsl:stylesheet");
}
}
while (compiler.Advance());
compiler.ToParent();
//.........这里部分代码省略.........
示例7: CompileDocument
// CompileTopLevelElements
protected void CompileDocument(Compiler compiler, bool inInclude) {
NavigatorInput input = compiler.Input;
// SkipToElement :
while (input.NodeType != XPathNodeType.Element) {
if (! compiler.Advance()) {
throw new XsltException(Res.Xslt_WrongStylesheetElement);
}
}
Debug.Assert(compiler.Input.NodeType == XPathNodeType.Element);
if (Keywords.Equals(input.NamespaceURI, input.Atoms.XsltNamespace)) {
if (
! Keywords.Equals(input.LocalName, input.Atoms.Stylesheet) &&
! Keywords.Equals(input.LocalName, input.Atoms.Transform)
) {
throw new XsltException(Res.Xslt_WrongStylesheetElement);
}
compiler.PushNamespaceScope();
CompileStylesheetAttributes(compiler);
CompileTopLevelElements(compiler);
if (! inInclude) {
CompileImports(compiler);
}
}
else {
// single template
compiler.PushLiteralScope();
CompileSingleTemplate(compiler);
}
compiler.PopScope();
}