Hi all, How can I provide an external XSD to an XML? What kind of line should be added to the XML Clara -- thank you so much for your help
clara wrote: > How can I provide an external XSD to an XML? What kind of line should be > added to the XML Do you want to link an XML instance document to a schema? You can use the xsi:noNamespaceSchemaLocation e.g. <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://example.com/schema.xsd"> <foo>bar</foo> </root> for that respectively xsi:schemaLocation <root xmlns="http://example.com/2008/ns1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/2008/ns1 http://example.com/schema.xsd"> <foo>bar</foo> </root> -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Hi Martin, thanks for your reply, could you explain why there are two https in the <xsi:schemaLoaction="..."> part. <root xmlns="http://example.com/2008/ns1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://example.com/2008/ns1 http://example.com/schema.xsd"> <foo>bar</foo> </root> It seems to me that the schema is applied to the <root> element( I am newbie so I am not sure about it), could you show me how to apply it to whole XML file? Clara -- thank you so much for your help "Martin Honnen" wrote: > clara wrote: > > > How can I provide an external XSD to an XML? What kind of line should be > > added to the XML > > Do you want to link an XML instance document to a schema? You can use > the xsi:noNamespaceSchemaLocation e.g. > <root > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:noNamespaceSchemaLocation="http://example.com/schema.xsd"> > > <foo>bar</foo> > </root> > for that respectively xsi:schemaLocation > <root > xmlns="http://example.com/2008/ns1" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation="http://example.com/2008/ns1 > http://example.com/schema.xsd"> > > <foo>bar</foo> > </root> > > > > > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ >
clara wrote: > thanks for your reply, could you explain why there are two https in the > <xsi:schemaLoaction="..."> part. There are two URIs, the first is the namespace URI, the second points to the schema for that namespace. > It seems to me that the schema is applied to the <root> element( I am newbie > so I am not sure about it), could you show me how to apply it to whole XML > file? The schema location is given on the root element, that is right, but the schema applies to the complete document. See <URL:http://www.w3.org/TR/xmlschema-0/#schemaLocation> for a more detailed explanation. -- Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/