XSD 파일의 목적은 무엇입니까?
C # (. NET)에서 XML 파일을 쿼리 할 수 있는데 왜 XSD 파일이 필요한가요? 특정 XML 파일의 메타 데이터 파일이라는 것을 알고 있습니다. XSD에서 관계를 지정할 수 있지만 그 기능은 무엇입니까?
XML
<?xml version="1.0" encoding="utf-8" ?>
<Root>
<Customers>
<Customer CustomerID="GREAL">
<CompanyName>Great Lakes Food Market</CompanyName>
<ContactName>Howard Snyder</ContactName>
<ContactTitle>Marketing Manager</ContactTitle>
<Phone>(503) 555-7555</Phone>
<FullAddress>
<Address>2732 Baker Blvd.</Address>
<City>Eugene</City>
<Region>OR</Region>
<PostalCode>97403</PostalCode>
<Country>USA</Country>
</FullAddress>
</Customer>
</Customers>
<Orders>
<Order>
<CustomerID>GREAL</CustomerID>
<EmployeeID>6</EmployeeID>
<OrderDate>1997-05-06T00:00:00</OrderDate>
<RequiredDate>1997-05-20T00:00:00</RequiredDate>
<ShipInfo ShippedDate="1997-05-09T00:00:00">
<ShipVia>2</ShipVia>
<Freight>3.35</Freight>
<ShipName>Great Lakes Food Market</ShipName>
<ShipAddress>2732 Baker Blvd.</ShipAddress>
<ShipCity>Eugene</ShipCity>
<ShipRegion>OR</ShipRegion>
<ShipPostalCode>97403</ShipPostalCode>
<ShipCountry>USA</ShipCountry>
</ShipInfo>
</Order>
<Order>
<CustomerID>GREAL</CustomerID>
<EmployeeID>8</EmployeeID>
<OrderDate>1997-07-04T00:00:00</OrderDate>
<RequiredDate>1997-08-01T00:00:00</RequiredDate>
<ShipInfo ShippedDate="1997-07-14T00:00:00">
<ShipVia>2</ShipVia>
<Freight>4.42</Freight>
<ShipName>Great Lakes Food Market</ShipName>
<ShipAddress>2732 Baker Blvd.</ShipAddress>
<ShipCity>Eugene</ShipCity>
<ShipRegion>OR</ShipRegion>
<ShipPostalCode>97403</ShipPostalCode>
<ShipCountry>USA</ShipCountry>
</ShipInfo>
</Order>
</Orders>
</Root>
Order
제공된에 따라 요소 에서 데이터를 얻고 싶습니다 CustomerID
.
또한 : XSD에서 관계를 제공하는 목적은 무엇입니까?
XSD 파일은 XML 파일이 특정 형식을 따르는 지 확인하는 데 사용됩니다.
그 점에서 그들은 이전에 존재했던 DTD 와 유사 합니다.
XSD와 DTD의 가장 큰 차이점은 XSD는 XML로 작성되며 읽기 쉽고 이해하기 쉽다는 것입니다.
Without XML Schema (XSD file) an XML file is a relatively free set of elements and attributes. The XSD file defines which elements and attributes are permitted and in which order.
In general XML is a metalanguage. XSD files define specific languages within that metalanguage. For example, if your XSD file contains the definition of XHTML 1.0, then your XML file is required to fit XHTML 1.0 rather than some other format.
You mention C# in your question so it may help to think of as XSD as serving a similar role to a C# interface.
It defines what the XML should 'look like' in a similar way that an interface defines what a class should implement.
XSDs constrain the vocabulary and structure of XML documents.
- Without an XSD, an XML document need only follow the rules for being well-formed as given in the W3C XML Recommendation.
- With an XSD, an XML document must adhere to additional constraints placed upon the names and values of its elements and attributes in order to be considered valid against the XSD per the W3C XML Schema Recommendation.
XML is all about agreement, and XSDs provide the means for structuring and communicating the agreement beyond the basic definition of XML itself.
Also questions is: What is the purpose of giving the relationships in xsd.
Suppose you want to generate some XML for an external party's tool, or similar - how would you know what structure it is allowed to follow to be used correctly for their tool? you write to a schema. Likewise if you want other people to use your tool, you would write a schema for them to follow. It may also be useful for validating your own XML.
Before understanding the XSD(XML Schema Definition) let me explain;
What is schema?
for example; emailID: peter#gmail
You can identify the above emailID is not valid because there is no @, .com or .net or .org.
We know the email schema it looks like peter@gmail.com.
Conclusion: Schema does not validate the data, It does the validation of structure.
XSD is actually one of the implementation of XML Schema. others we have relaxng
We use XSD to validate XML data.
An XSD is a formal contract that specifies how an XML document can be formed. It is often used to validate an XML document, or to generate code from.
An XSD file is an XML Schema Definition and it is used to provide a standard method of checking that a given XML document conforms to what you expect.
An .xsd file is called an XML schema. Via an XML schema, we may require a certain structure in a given XML - which elements in which order, how many times, with which attributes, how they are nested, etc. If we have a schema for our XML input, we can verify that it contains the data we need it to contain, and nothing else, with a few lines invoking a schema validator.
The xsd file is the schema of the xml file - it defines which elements may occur and their restrictions (like amount, order, boundaries, relationships,...)
참고URL : https://stackoverflow.com/questions/3403644/what-is-the-purpose-of-xsd-files
'developer tip' 카테고리의 다른 글
interface {}를 문자열로 변환하는 방법은 무엇입니까? (0) | 2020.09.11 |
---|---|
C 포인터를 NULL로 초기화 할 수 있습니까? (0) | 2020.09.11 |
Ruby on Rails Database.yml 파일의 MySQL 구성 수정 (0) | 2020.09.11 |
Intent.EXTRA_EMAIL이받는 사람 필드를 채우지 않습니다. (0) | 2020.09.11 |
Twitter Bootstrap을 사용하여 테이블 셀에서 세로로 버튼 중앙에 배치 (0) | 2020.09.11 |