本文整理汇总了C#中XmlQualifiedName.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlQualifiedName.ToString方法的具体用法?C# XmlQualifiedName.ToString怎么用?C# XmlQualifiedName.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlQualifiedName
的用法示例。
在下文中一共展示了XmlQualifiedName.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveVariable
// --------------------------- XsltContext -------------------
// Resolving variables and functions
public override IXsltContextVariable ResolveVariable(string prefix, string name) {
string namespaceURI = this.LookupNamespace(prefix);
XmlQualifiedName qname = new XmlQualifiedName(name, namespaceURI);
IXsltContextVariable variable = this.manager.VariableScope.ResolveVariable(qname);
if (variable == null) {
throw XsltException.Create(Res.Xslt_InvalidVariable, qname.ToString());
}
return variable;
}
示例2: CheckContent
internal void CheckContent(ValidationState context, XmlQualifiedName qname, ref XmlSchemaContentProcessing processContents) {
#if DEBUG
Debug.WriteLineIf(CompModSwitches.XmlSchema.TraceVerbose, String.Format("\t\t\tSchemaContentModel.CheckContent({0}) in \"{1}\"", "\"" + qname.ToString() + "\"", context.Name));
#endif
XmlQualifiedName n = qname.IsEmpty ? (schemaNames == null ? XmlQualifiedName.Empty : schemaNames.QnPCData) : qname;
Object lookup;
if (context.IsNill) {
throw new XmlSchemaException(Res.Sch_ContentInNill, context.Name.ToString());
}
switch(contentType) {
case CompiledContentModel.Type.Any:
context.HasMatched = true;
return;
case CompiledContentModel.Type.Empty:
goto error;
case CompiledContentModel.Type.Text:
if(qname.IsEmpty)
return;
else
goto error;
case CompiledContentModel.Type.Mixed:
if (qname.IsEmpty)
return;
break;
case CompiledContentModel.Type.ElementOnly:
if (qname.IsEmpty)
goto error;
break;
default:
break;
}
if (IsAllElements) {
lookup = symbolTable[n];
if (lookup != null) {
int index = (int)lookup;
if (context.AllElementsSet.Get(index)) {
throw new XmlSchemaException(Res.Sch_AllElement, qname.Name);
}
else {
context.AllElementsSet.Set(index);
}
}
else {
goto error;
}
return;
}
if (!IsCompiled) {
CheckXsdContent(context, qname, ref processContents);
return;
}
lookup = symbolTable[n];
if (lookup != null) {
int sym = (int)lookup;
if (sym != -1 && dtrans != null) {
int state = ((int[])dtrans[context.State])[sym];
if (state != -1) {
context.State = state;
context.HasMatched = ((int[])dtrans[context.State])[symbols.Count] > 0;
return;
}
}
}
if (IsOpen && context.HasMatched) {
// XDR allows any well-formed contents after matched.
return;
}
//
// report error
//
context.NeedValidateChildren = false;
error:
ArrayList v = null;
if (dtrans != null) {
v = ExpectedElements(context.State, context.AllElementsSet);
}
if (v == null || v.Count == 0) {
if (!(qname.IsEmpty)) {
throw new XmlSchemaException(Res.Sch_InvalidElementContent, new string[] { context.Name.ToString(), n.ToString() });
}
else {
if (n.Name.Equals("#PCDATA")) {
if(contentType == CompiledContentModel.Type.Empty)
throw new XmlSchemaException(Res.Sch_InvalidTextWhiteSpace);
else
throw new XmlSchemaException(Res.Sch_InvalidTextInElement,context.Name.ToString());
//.........这里部分代码省略.........
示例3: AddTerminal
internal void AddTerminal(XmlQualifiedName qname, String prefix, ValidationEventHandler eventHandler) {
if (schemaNames.QnPCData.Equals(qname)) {
nodeTable = new Hashtable();
}
else if (nodeTable != null) {
if (nodeTable.ContainsKey(qname)) {
if (eventHandler != null) {
eventHandler(
this,
new ValidationEventArgs(
new XmlSchemaException(Res.Sch_DupElement, qname.ToString())
)
);
}
//notice: should not return here!
}
else {
nodeTable.Add(qname, qname);
}
}
ContentNode n = NewTerminalNode(qname);
if (stack.Count > 0) {
InternalNode inNode = (InternalNode)stack.Pop();
if (inNode != null) {
inNode.RightNode = n;
n.ParentNode = inNode;
n = inNode;
}
}
stack.Push( n );
isPartial = true;
}
示例4: FindElement
XmlSchemaElement FindElement(XmlQualifiedName name) {
XmlSchemaElement element = (XmlSchemaElement)schemas.Find(name, typeof(XmlSchemaElement));
if (element == null) throw new InvalidOperationException(Res.GetString(Res.XmlMissingElement, name.ToString()));
return element;
}
示例5: FindDataType
XmlSchemaSimpleType FindDataType(XmlQualifiedName name) {
TypeDesc typeDesc = scope.GetTypeDesc(name);
if (typeDesc != null)
return typeDesc.DataType;
XmlSchemaSimpleType dataType = (XmlSchemaSimpleType)schemas.Find(name, typeof(XmlSchemaSimpleType));
if (dataType != null)
return dataType;
if (name.Namespace == XmlSchema.Namespace)
return scope.GetTypeDesc(typeof(string)).DataType;
else {
if (name.Name == Soap.Array && name.Namespace == Soap.Encoding) {
throw new InvalidOperationException(Res.GetString(Res.XmlInvalidEncoding, name.ToString()));
}
else {
throw new InvalidOperationException(Res.GetString(Res.XmlMissingDataType, name.ToString()));
}
}
}
示例6: GetAttributeXdr
public SchemaAttDef GetAttributeXdr(SchemaElementDecl ed, XmlQualifiedName qname) {
SchemaAttDef attdef = null;
if (ed != null) {
attdef = ed.GetAttDef(qname);;
if (attdef == null) {
if (!ed.ContentValidator.IsOpen || qname.Namespace.Length == 0) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
attdef = (SchemaAttDef)attributeDecls[qname];
if (attdef == null && targetNamespaces.Contains(qname.Namespace)) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
}
}
return attdef;
}
示例7: AddToTable
private void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
if (qname.Name == string.Empty) {
return;
}
else if (table[qname] != null) {
string code = Res.Sch_DupGlobalAttribute;
if (item is XmlSchemaAttributeGroup) {
code = Res.Sch_DupAttributeGroup;
}
else if (item is XmlSchemaComplexType) {
code = Res.Sch_DupComplexType;
}
else if (item is XmlSchemaSimpleType) {
code = Res.Sch_DupSimpleType;
}
else if (item is XmlSchemaElement) {
code = Res.Sch_DupGlobalElement;
}
else if (item is XmlSchemaGroup) {
code = Res.Sch_DupGroup;
}
else if (item is XmlSchemaNotation) {
code = Res.Sch_DupNotation;
}
SendValidationEvent(code, qname.ToString(), item);
}
else {
table.Add(qname, item);
}
}
示例8: CheckValueFacets
internal override Exception CheckValueFacets(XmlQualifiedName value, XmlSchemaDatatype datatype) {
RestrictionFacets restriction = datatype.Restriction;
RestrictionFlags flags = restriction != null ? restriction.Flags : 0;
if (flags != 0) { //If there are facets defined
string strValue = value.ToString();
int length = strValue.Length;
if ((flags & RestrictionFlags.Length) != 0) {
if (restriction.Length != length) {
return new XmlSchemaException(Res.Sch_LengthConstraintFailed, string.Empty);
}
}
if ((flags & RestrictionFlags.MinLength) != 0) {
if (length < restriction.MinLength) {
return new XmlSchemaException(Res.Sch_MinLengthConstraintFailed, string.Empty);
}
}
if ((flags & RestrictionFlags.MaxLength) != 0) {
if (restriction.MaxLength < length) {
return new XmlSchemaException(Res.Sch_MaxLengthConstraintFailed, string.Empty);
}
}
if ((flags & RestrictionFlags.Enumeration) != 0) {
if (!MatchEnumeration(value, restriction.Enumeration)) {
return new XmlSchemaException(Res.Sch_EnumerationConstraintFailed, string.Empty);
}
}
}
return null;
}
示例9: ThoroughGetElementDecl
private SchemaElementDecl ThoroughGetElementDecl(SchemaElementDecl elementDecl, XmlQualifiedName xsiType, string xsiNil)
{
if (elementDecl == null)
{
elementDecl = schemaInfo.GetElementDecl(elementName);
}
if (elementDecl != null)
{
if (xsiType.IsEmpty)
{
if (elementDecl.IsAbstract)
{
SendValidationEvent(SR.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
elementDecl = null;
}
}
else if (xsiNil != null && xsiNil.Equals("true"))
{
SendValidationEvent(SR.Sch_XsiNilAndType);
}
else
{
SchemaElementDecl elementDeclXsi;
if (!schemaInfo.ElementDeclsByType.TryGetValue(xsiType, out elementDeclXsi) && xsiType.Namespace == _nsXs)
{
XmlSchemaSimpleType simpleType = DatatypeImplementation.GetSimpleTypeFromXsdType(new XmlQualifiedName(xsiType.Name, _nsXs));
if (simpleType != null)
{
elementDeclXsi = simpleType.ElementDecl;
}
}
if (elementDeclXsi == null)
{
SendValidationEvent(SR.Sch_XsiTypeNotFound, xsiType.ToString());
elementDecl = null;
}
else if (!XmlSchemaType.IsDerivedFrom(elementDeclXsi.SchemaType, elementDecl.SchemaType, elementDecl.Block))
{
SendValidationEvent(SR.Sch_XsiTypeBlockedEx, new string[] { xsiType.ToString(), XmlSchemaValidator.QNameString(context.LocalName, context.Namespace) });
elementDecl = null;
}
else
{
elementDecl = elementDeclXsi;
}
}
if (elementDecl != null && elementDecl.IsNillable)
{
if (xsiNil != null)
{
context.IsNill = XmlConvert.ToBoolean(xsiNil);
if (context.IsNill && elementDecl.DefaultValueTyped != null)
{
SendValidationEvent(SR.Sch_XsiNilAndFixed);
}
}
}
else if (xsiNil != null)
{
SendValidationEvent(SR.Sch_InvalidXsiNill);
}
}
return elementDecl;
}
示例10: ValidateStartElement
private void ValidateStartElement()
{
if (context.ElementDecl != null)
{
if (context.ElementDecl.IsAbstract)
{
SendValidationEvent(SR.Sch_AbstractElement, XmlSchemaValidator.QNameString(context.LocalName, context.Namespace));
}
reader.SchemaTypeObject = context.ElementDecl.SchemaType;
if (reader.IsEmptyElement && !context.IsNill && context.ElementDecl.DefaultValueTyped != null)
{
reader.TypedValueObject = UnWrapUnion(context.ElementDecl.DefaultValueTyped);
context.IsNill = true; // reusing IsNill
}
else
{
reader.TypedValueObject = null; //Typed value cleanup
}
if (this.context.ElementDecl.HasRequiredAttribute || HasIdentityConstraints)
{
_attPresence.Clear();
}
}
if (reader.MoveToFirstAttribute())
{
do
{
if ((object)reader.NamespaceURI == (object)_nsXmlNs)
{
continue;
}
if ((object)reader.NamespaceURI == (object)_nsXsi)
{
continue;
}
try
{
reader.SchemaTypeObject = null;
XmlQualifiedName attQName = new XmlQualifiedName(reader.LocalName, reader.NamespaceURI);
bool skipContents = (_processContents == XmlSchemaContentProcessing.Skip);
SchemaAttDef attnDef = schemaInfo.GetAttributeXsd(context.ElementDecl, attQName, ref skipContents);
if (attnDef != null)
{
if (context.ElementDecl != null && (context.ElementDecl.HasRequiredAttribute || _startIDConstraint != -1))
{
_attPresence.Add(attnDef.Name, attnDef);
}
Debug.Assert(attnDef.SchemaType != null);
reader.SchemaTypeObject = attnDef.SchemaType;
if (attnDef.Datatype != null)
{
// need to check the contents of this attribute to make sure
// it is valid according to the specified attribute type.
CheckValue(reader.Value, attnDef);
}
if (HasIdentityConstraints)
{
AttributeIdentityConstraints(reader.LocalName, reader.NamespaceURI, reader.TypedValueObject, reader.Value, attnDef);
}
}
else if (!skipContents)
{
if (context.ElementDecl == null
&& _processContents == XmlSchemaContentProcessing.Strict
&& attQName.Namespace.Length != 0
&& schemaInfo.Contains(attQName.Namespace)
)
{
SendValidationEvent(SR.Sch_UndeclaredAttribute, attQName.ToString());
}
else
{
SendValidationEvent(SR.Sch_NoAttributeSchemaFound, attQName.ToString(), XmlSeverityType.Warning);
}
}
}
catch (XmlSchemaException e)
{
e.SetSource(reader.BaseURI, PositionInfo.LineNumber, PositionInfo.LinePosition);
SendValidationEvent(e);
}
} while (reader.MoveToNextAttribute());
reader.MoveToElement();
}
}
示例11: AddToTable
protected void AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
if (qname.Name.Length == 0) {
return;
}
XmlSchemaObject existingObject = (XmlSchemaObject)table[qname];
if (existingObject != null) {
if (existingObject == item) {
return;
}
string code = Res.Sch_DupGlobalElement;
if (item is XmlSchemaAttributeGroup) {
string ns = nameTable.Add(qname.Namespace);
if (Ref.Equal(ns, NsXml)) { //Check for xml namespace
XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
XmlSchemaObject builtInAttributeGroup = schemaForXmlNS.AttributeGroups[qname];
if ((object)existingObject == (object)builtInAttributeGroup) {
table.Insert(qname, item);
return;
}
else if ((object)item == (object)builtInAttributeGroup) { //trying to overwrite customer's component with built-in, ignore built-in
return;
}
}
else if (IsValidAttributeGroupRedefine(existingObject, item, table)){ //check for redefines
return;
}
code = Res.Sch_DupAttributeGroup;
}
else if (item is XmlSchemaAttribute) {
string ns = nameTable.Add(qname.Namespace);
if (Ref.Equal(ns, NsXml)) {
XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname];
if ((object)existingObject == (object)builtInAttribute) { //replace built-in one
table.Insert(qname, item);
return;
}
else if ((object)item == (object)builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in
return;
}
}
code = Res.Sch_DupGlobalAttribute;
}
else if (item is XmlSchemaSimpleType) {
if (IsValidTypeRedefine(existingObject, item, table)) {
return;
}
code = Res.Sch_DupSimpleType;
}
else if (item is XmlSchemaComplexType) {
if (IsValidTypeRedefine(existingObject, item, table)) {
return;
}
code = Res.Sch_DupComplexType;
}
else if (item is XmlSchemaGroup) {
if (IsValidGroupRedefine(existingObject, item, table)){ //check for redefines
return;
}
code = Res.Sch_DupGroup;
}
else if (item is XmlSchemaNotation) {
code = Res.Sch_DupNotation;
}
else if (item is XmlSchemaIdentityConstraint) {
code = Res.Sch_DupIdentityConstraint;
}
else {
Debug.Assert(item is XmlSchemaElement);
}
SendValidationEvent(code, qname.ToString(), item);
}
else {
table.Add(qname, item);
}
}
示例12: GetAttribute
internal SchemaAttDef GetAttribute(SchemaElementDecl ed, XmlQualifiedName qname, out bool skip) {
SchemaAttDef attdef = null;
skip = false;
if (ed != null) { // local attribute or XSD
attdef = ed.GetAttDef(qname);
if (attdef == null) {
// In DTD, every attribute must be declared.
if (schemaType == SchemaType.DTD) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
else if (schemaType == SchemaType.XDR) {
if (ed.Content.IsOpen) {
attdef = (SchemaAttDef)attributeDecls[qname];
if ((attdef == null) && ((qname.Namespace == String.Empty) || HasSchema(qname.Namespace))) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
}
else { //XML Schema
XmlSchemaAnyAttribute any = ed.AnyAttribute;
if (any != null) {
if (any.NamespaceList.Allows(qname) && ed.ProhibitedAttributes[qname] == null) {
if (any.ProcessContentsCorrect != XmlSchemaContentProcessing.Skip) {
attdef = (SchemaAttDef)attributeDecls[qname];
if (attdef == null && any.ProcessContentsCorrect == XmlSchemaContentProcessing.Strict) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
}
else {
skip = true;
}
}
else {
throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());
}
}
else if (ed.ProhibitedAttributes[qname] != null) {
throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());
}
else {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
}
}
}
else { // global attribute
attdef = (SchemaAttDef)attributeDecls[qname];
if ((attdef == null) && HasSchema(qname.Namespace)) {
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
}
}
return attdef;
}
示例13: GetAttributeXsd
public SchemaAttDef GetAttributeXsd(SchemaElementDecl ed, XmlQualifiedName qname, ref bool skip) {
AttributeMatchState attributeMatchState;
SchemaAttDef attDef = GetAttributeXsd(ed, qname, null, out attributeMatchState);
switch(attributeMatchState) {
case AttributeMatchState.UndeclaredAttribute:
throw new XmlSchemaException(Res.Sch_UndeclaredAttribute, qname.ToString());
case AttributeMatchState.ProhibitedAnyAttribute:
case AttributeMatchState.ProhibitedAttribute:
throw new XmlSchemaException(Res.Sch_ProhibitedAttribute, qname.ToString());
case AttributeMatchState.AttributeFound:
case AttributeMatchState.AnyAttributeLax:
case AttributeMatchState.UndeclaredElementAndAttribute:
break;
case AttributeMatchState.AnyAttributeSkip:
skip = true;
break;
default:
Debug.Assert(false);
break;
}
return attDef;
}
示例14: ProcessElement
internal override bool ProcessElement(string prefix, string name, string ns) {
XmlQualifiedName qname = new XmlQualifiedName(name, ns);
if (GetNextState(qname)) {
Push();
Debug.Assert(this.currentEntry.InitFunc != null);
xso = null;
this.currentEntry.InitFunc(this, null);
Debug.Assert(xso != null);
RecordPosition();
}
else {
if (!IsSkipableElement(qname)) {
SendValidationEvent(Res.Sch_UnsupportedElement, qname.ToString());
}
return false;
}
return true;
}
示例15: AddToTable
private bool AddToTable(XmlSchemaObjectTable table, XmlQualifiedName qname, XmlSchemaObject item) {
if (qname.Name.Length == 0) {
return true;
}
XmlSchemaObject existingObject = (XmlSchemaObject)table[qname];
if (existingObject != null) {
if (existingObject == item || existingObject.SourceUri == item.SourceUri) {
return true;
}
string code = string.Empty;
if (item is XmlSchemaComplexType) {
code = Res.Sch_DupComplexType;
}
else if (item is XmlSchemaSimpleType) {
code = Res.Sch_DupSimpleType;
}
else if (item is XmlSchemaElement) {
code = Res.Sch_DupGlobalElement;
}
else if (item is XmlSchemaAttribute) {
if (qname.Namespace == XmlReservedNs.NsXml) {
XmlSchema schemaForXmlNS = Preprocessor.GetBuildInSchema();
XmlSchemaObject builtInAttribute = schemaForXmlNS.Attributes[qname];
if (existingObject == builtInAttribute) { //replace built-in one
table.Insert(qname, item);
return true;
}
else if (item == builtInAttribute) { //trying to overwrite customer's component with built-in, ignore built-in
return true;
}
}
code = Res.Sch_DupGlobalAttribute;
}
SendValidationEvent(new XmlSchemaException(code,qname.ToString()), XmlSeverityType.Error);
return false;
}
else {
table.Add(qname, item);
return true;
}
}