XmlSchemaAttributeGroup contains a Public property that is named RedefinedAttributeGroup (317548)



The information in this article applies to:

  • Microsoft Windows .NET Framework Class Libraries 1.1
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft XML Classes (included with the .NET Framework 1.0)

This article was previously published under Q317548

SUMMARY

The XmlSchemaAttributeGroup contains a Public property called RedefinedAttributeGroup that is not documented in Microsoft Developer Network (MSDN). This is a read-only property and retrieves the redefined attribute group from the XSD schema.

MORE INFORMATION

The following sample shows how to use the RedefinedAttributeGroup property.

NOTE: This is a read-only property when you query the XSD schema.
  1. Create a new Microsoft Visual Basic .NET console application.
  2. Replace the code in the Module1.vb file with the following code:
    Module Module1
    
        Dim xReader As System.Xml.XmlReader = New System.Xml.XmlTextReader("c:\test.xml")
        Dim xValidator As System.Xml.XmlValidatingReader = New System.Xml.XmlValidatingReader(xReader)
        Dim sQualifiedName As System.Xml.XmlQualifiedName = New System.Xml.XmlQualifiedName("car")
        Dim sGroup As System.Xml.Schema.XmlSchemaAttributeGroup
    
    
        Sub Main()
            xValidator.Schemas.Add("", "c:\test.xsd")
            xValidator.ValidationType = System.Xml.ValidationType.Schema
    
            sGroup = xValidator.Schemas.Item("").AttributeGroups(sQualifiedName)
    
            Console.WriteLine("Name: " & sGroup.RedefinedAttributeGroup.Name & vbCrLf)
            Console.WriteLine("LineNumber: " & sGroup.RedefinedAttributeGroup.LineNumber & vbCrLf)
            Console.WriteLine("LinePosition: " & sGroup.RedefinedAttributeGroup.LinePosition & vbCrLf)
            Console.WriteLine("Namespaces Count: " & sGroup.RedefinedAttributeGroup.Namespaces.Count & vbCrLf)
            Console.WriteLine("SourceUri: " & sGroup.RedefinedAttributeGroup.SourceUri & vbCrLf)
    
            Console.Read()
    
        End Sub
    
    End Module
    					
  3. Paste the following Extensible Markup Language (XML) code into a file in the C:\ directory and name it "Test.xml" (without quotation marks):
    <doc  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' 
    	xsi:noNamespaceSchemaLocation="test.xsd" >
    	<test attFix="38" />
    </doc>
    					
  4. Paste the following XML code into a file in the C:\ directory and name it "Test.xsd" (without quotation marks):
    <?xml version="1.0" ?>
    <xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
    	<xsd:redefine schemaLocation="testredefine.xsd">
    		<xsd:attributeGroup name="car">
    			<xsd:attributeGroup ref="car" />
    		</xsd:attributeGroup>
    	</xsd:redefine>
    	<xsd:attribute name="att1" type="xsd:string" />
    	<xsd:attributeGroup name="ext">
    		<xsd:attributeGroup ref="car" />
    	</xsd:attributeGroup>
    	<xsd:element name="doc">
    		<xsd:complexType>
    			<xsd:sequence>
    				<xsd:element name="test">
    					<xsd:complexType>
    						<xsd:attributeGroup ref="ext" />
    					</xsd:complexType>
    				</xsd:element>
    			</xsd:sequence>
    		</xsd:complexType>
    	</xsd:element>
    </xsd:schema>
    					
  5. Paste the following XML code into a file in the C:\ directory and name it "Testredefine.xsd" (without quotation marks):
    <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    	<xsd:attribute name="model" type="xsd:string" />
    	<xsd:attributeGroup name="car">
    		<xsd:attribute name="model" />
    		<xsd:attribute name="age" type="xsd:int" />
    		<xsd:attribute name="attFix" type="xsd:int" fixed="37" />
    	</xsd:attributeGroup>
    	<xsd:attributeGroup name="truck">
    		<xsd:attribute name="model" />
    		<xsd:attribute name="age" type="xsd:int" />
    	</xsd:attributeGroup>
    	<xsd:complexType name="Address1">
    		<xsd:complexContent>
    			<xsd:extension base="Address">
    				<xsd:sequence>
    					<xsd:element name="country" type="xsd:string" />
    				</xsd:sequence>
    			</xsd:extension>
    		</xsd:complexContent>
    	</xsd:complexType>
    	<xsd:complexType name="Address">
    		<xsd:sequence>
    			<xsd:element name="name" type="xsd:string" />
    			<xsd:element name="street" type="xsd:string" />
    			<xsd:element name="city" type="xsd:string" />
    		</xsd:sequence>
    	</xsd:complexType>
    </xsd:schema>
    					
  6. Compile and run the application. The following output should appear:
    Name: car
    LineNumber: 3
    LinePosition: 3
    Namespaces Count: 0
    SourceUri: file:///c:/testredefine.xsd
    					

Modification Type:MinorLast Reviewed:9/15/2005
Keywords:kbvs2002sp1sweep kbbug kbdocerr kbpending KB317548