아래와 같은 XML 파일의 예를 보았습니다.
<root xmlns:h="http://www.w3.org/TR/html4/"
xmlns:f="http://www.w3schools.com/furniture">
<h:table>
<h:tr>
<h:td>Apples</h:td>
<h:td>Bananas</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
또한 다음 XML 파일을 보았습니다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="test" />
</beans>
첫 번째는 접두사가 필요하고 두 번째는 그렇지 않은 이유에 대해 혼란 스럽습니다. 모호한 경우에만 접두사가 필요합니까? 2nd의 루트 태그 선언에 접두사가 선택 사항이되는 것이 있습니까?
이것은 매우 기본적인 것입니다.
첫 번째 경우 root
요소는 기본 네임 스페이스에 있습니다. 두 table
요소는 서로 다른 두 네임 스페이스에 있으므로 f
및 h
접두사가 있습니다.
두 번째 경우 beans
요소는 http://www.springframework.org/schema/beans
네임 스페이스에 있습니다. 다음과 같은 접두사로 지정되었을 수 있습니다.
<b:beans xmlns:b="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<b:bean id="test" />
</b:beans>
그러나 네임 스페이스가 하나뿐이므로 xmlns="http://www.springframework.org/schema/beans
모든 요소에 대한 네임 스페이스 로 지정 하는 것이 더 간단합니다 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다