views:

53

answers:

1

Hello SO,

My xml file is structures like below

<outer> 
  <inner name="nam" attribute1="abc" attribute2="def" />
</outer>

Now, the only attribute I am assured of in the 'inner' tag is the 'name' attribute. Other than that I do not want to apply any restriction on the name or number of attributes the 'inner' tag can have. That would imply that my xml file could also look like

 <outer> 
      <inner name="nam2" wallace="abc" gromit="def" wererabbit="what" />
 </outer>

I would however still want to be able to validate my XML file using a XSD.And here is the complexType I have tried to define in my xsd to do this job. But the validation fails as apparently the validator expects every attribute to be specified in the xsd and I can not do that because the attributes can be anything and are not decided before hand.

<xs:complexType name="innerType">
 <xs:attribute name="name" type="xs:string"/>
</xs:complexType>

I was wondering if there was something in XSD( like ellipses perhaps? ) which would let me specify / overlook the variable number of attributes and validate the XML successfully.

Thanks,

Rohan

A: 

Folks,

This is a valid XSD for my question. Thanks to Mark. I apologize Mark. I was trying to get anyAttribute to work all of this evening but for some reason it never worked till I tried it the way below. If you could please re post your answer , I will go ahead and vote it as the right answer.

<xs:complexType name="innerType">
 <xs:attribute name="name" type="xs:string" use="required"/>
 <xs:anyAttribute processContents="skip"/>
</xs:complexType>

Thanks, Rohan

rohangter