Schema Infoset Model·Î ½ºÅ°¸¶¿¡ ´ëÇÑ º¹ÀâÇÑ Äõ¸®¸¦ °£´ÜÈ÷!
Shane
Curcuru Advisory Software Engineer, IBM June
2002
½ºÅ°¸¶(Schema)°¡ º¹ÀâÇØÁö¸é ½ºÅ°¸¶¸¦ Á¶ÀÛÇÒ Åø¿¡ ´ëÇÑ ÇÊ¿äµµ ¸¹¾ÆÁö°Ô µÈ´Ù.
»õ·Î¿î Schema Infoset ModelÀº ½ºÅ°¸¶ ÀÚüÀÇ ¿Ïº®ÇÑ ¸ðµ¨¸µ »Ó¸¸ ¾Æ´Ï¶ó ±¸Ã¼ÀûÀÎ ±¸Çö°ú
½ºÅ°¸¶ ¶Ç´Â ½ºÅ°¸¶ ¼¼Æ®¿¡¼ÀÇ Ãß»ó °ü°è¸¦ º¸¿©ÁØ´Ù. ÀÌ ±Û¿¡¼´Â ½ºÅ°¸¶ ¸ðµ¨À» ½±°Ô ¿äûÇÒ ¼ö ÀÖ´Â
¶óÀ̺귯¸®¸¦ ¼³¸íÇÑ´Ù. ¸ðµç ¹®Á¦¸¦ ÇØ°áÇϵµ·Ï ½ºÅ°¸¶¸¦ ¾÷µ¥ÀÌÆ® ÇÒ ¼ö ÀÖ´Â ¹æ¹ýµµ Á¦½ÃÇÑ´Ù.
Note: ÀÌ ±ÛÀº ½ºÅ°¸¶ ¹®¼¿¡ ´ëÇØ ±âº»ÀûÀÎ Áö½ÄÀ» °®°íÀÖ´Ù´Â ÀüÁ¦ÇÏ¿¡ ÀÛ¼ºµÇ¾ú´Ù.
Âü°íÀÚ·á¿¡¼
½ºÅ°¸¶ ¹®¼¿Í Æ©Å丮¾ó Á¤º¸¸¦ ÂüÁ¶Çϱ⠹ٶõ´Ù.
XML ¹®¼¸¦ °ËÁõÇÏ°í ºÐ¼®ÇÏ´Â ½ºÅ°¸¶(Schema)¸¦ »ç¿ëÇÏ´Â Æļ¿Í ÅøµéÀº ¸¹ÀÌ À־ ÁúÀÇ¿Í ½ºÅ°¸¶
¹®¼ÀÇ °í±Þ Á¶ÀÛ ÅøÀº ¿©ÀüÈ÷ ±¸ÇöµÇ°í ÀÖ´Ù. Schema Infoset Model (AKA the IBM
Java Library for Schema Components ¶Ç´Â "¶óÀ̺귯¸®")´Â ½ºÅ°¸¶¸¦ ¸ðµ¨¸µÇϴ dzºÎÇÑ
API ¶óÀ̺귯¸®¸¦ Á¦°øÇÑ´Ù. ½ºÅ°¸¶ ½ºÆÑÀ» Àо »ç¶÷ÀÌ¸é ´©±¸³ª ¾Ë°ÚÁö¸¸ ¸Å¿ì ÀÚ¼¼ÇÏ°í ÀÌ ¸ðµ¨Àº ¾î¶²
½ºÅ°¸¶¿¡¼¶óµµ ¸ðµç ¼¼ºÎ»çÇ×À» ³ëÃâÇÑ´Ù. ÀÌ·¸°Ô µÇ¸é ½ºÅ°¸¶ ÄÝ·º¼ÇÀ» È¿À²ÀûÀ¸·Î °ü¸®ÇÒ ¼ö ÀÖ´Ù.
Schema Infoset Model UML
´ÙÀ̾î±×·¥
ÀÌ ¶óÀ̺귯¸®¿¡´Â ½ÇÁ¦ ¶óÀ̺귯¸® Ŭ·¡½º¸¦ À§ÇÑ ´Ù¾çÇÑ UML ´ÙÀ̾î±×·¥ÀÌ ÀÖ´Ù. ÀϹÝÀûÀÎ
½ºÅ°¸¶ ÄÄÆ÷³ÍÆ®ÀÇ °ü°è ¹× ¼Ó¼ºÀ» ºü¸£°Ô ¼³¸íÇØÁØ´Ù.
Abstract Schema Component °ü°è ÀÌ ´ÙÀ̾î±×·¥Àº Schema Infoset Component µéÀÇ °ü°è¸¦
º¸¿©ÁØ´Ù; ¶óÀ̺귯¸®¿¡ ¸ðµ¨¸µ µÉ ¶§ ½ºÅ°¸¶ °´Ã¼µé »çÀÌÀÇ Ãß»ó °ü°èÀÌ´Ù. °ËÀº ´ÙÀ̾Ƹóµå´Â °·ÂÇÑ
°áÇÕÀ» ÀǹÌÇÑ´Ù. °³¹æµÈ ´ÙÀ̾Ƹóµå´Â ¾àÇÑ °áÇÕÀ» ³ªÅ¸³½´Ù.
Abstract Schema Component ¼Ó¼º ÀÌ ´ÙÀ̾î±×·¥Àº ¶óÀ̺귯¸®¿¡ ¸ðµ¨¸µ µÉ ¶§ Ãß»ó ½ºÅ°¸¶ ÄÄÆ÷³ÍÆ®ÀÇ ¼Ó¼ºÀº
¹°·Ð Ŭ·¡½º °èÃþÀÇ ÀϺθ¦ º¸¿©ÁØ´Ù.
ÀÌ ´ÙÀ̾î±×·¥µéÀº ¶óÀ̺귯¸® ¹®¼¿¡ Æ÷ÇԵǾîÀÖ´Ù. Ãß»ó Ŭ·¡½º¿Í ±¸Ã¼ÀûÀΠŬ·¡½º Æ®¸®¸¦ À§ÇÑ
UML ´ÙÀ̾î±×·¥µµ ÀÖ´Ù. |
¸ðµ¨¸µ µÈ ¸ðµç ½ºÅ°¸¶ °´Ã¼µéÀ» º¸¿©ÁÖ´Â ¶óÀ̺귯¸®ÀÇ ÀÎÅÍÆäÀ̽º ¸ñ·ÏÀº Schema
Infoset Model UML ´ÙÀ̾î±×·¥À» ÂüÁ¶Çϱ⠹ٶõ´Ù. ÀÌ ¶óÀ̺귯¸®¿¡´Â ¶óÀ̺귯¸® ÀÎÅÍÆäÀ̽º¸¦
±¸ÇöÇϴµ¥ »ç¿ëµÇ´Â UML ´ÙÀ̾î±×·¥ÀÌ Æ÷ÇԵǾî ÀÖ´Ù. ÀÌ ´ÙÀ̾î±×·¥Àº ¶óÀ̺귯¸® °´Ã¼µéÀÇ °ü°è¸¦ º¸¿©ÁÖ¾î
½ºÅ°¸¶ ½ºÆÑÀÇ °³³äµéÀ» ¸Å¿ì À¯»çÇÏ°Ô ¸ð¹æÇÑ´Ù.
¿¹Á¦: ½ºÅ°¸¶
ºÐ¼®Çϱâ ÀÌ ¿¹Á¦¿¡¼ integer-derived À¯Çü Á¦ÇÑÀ» ¼³Á¤ÇÏ´Â °ÍÀ» ½ÇÆÐÇÒ
°æ¿ìÀÇ ½ºÅ°¸¶¸¦ Á¡°ËÇϱ⸦ ¿øÇÒ °ÍÀÌ´Ù. ÀÌ°ÍÀº ±¸¸Å ÁÖ¹®¼ÀÇ ±¸¸Å·®ÀÌ ´Ã¾î³µ´Ù´Â °ÍÀ» È®ÀÎÇϱ⿡ À¯¿ëÇÏ´Ù.
¿©±â¿¡¼ ½ºÅ°¸¶´Â ¸Å¿ì ±¸Ã¼ÀûÀÌ°í min/maxInclusive ¶Ç´Â min/maxExclusive Facet
Á¤¼ö ¿¡¼ ¾ò¾îÁø ¸ðµç °£´ÜÇÑ À¯ÇüµéÀÌ Æ÷ÇԵǾî¾ßÇÑ´Ù.
XSLT ¶Ç´Â XPath¸¦ »ç¿ëÇÏ¿© .xsd ÆÄÀÏ ¶Ç´Â ´Ù¸¥
.xml ³»¿ë¾È¿¡ ½ºÅ°¸¶ÀÇ ±¸Ã¼ÀûÀÎ ±¸ÇöÀ» Äõ¸®ÇÒ ¼ö´Â ÀÖÁö¸¸ ½ºÅ°¸¶ ÄÄÆ÷³ÍÆ®°¡ ½ÇÁ¦·Î
°®°í ÀÖ´Â À¯ÇüµµÃâ°ú »óÈ£ °ü°è¸¦ ¹ß°ßÇϱⰡ ÈξÀ ¾î·Á¿öÁø´Ù. Schema Infoset Model ¶óÀ̺귯¸®´Â
½ºÅ°¸¶ÀÇ ±¸Ã¼Àû ±¸Çö°ú Ãß»ó °³³ä ¸ðµÎ¸¦ ¸ðµ¨¸µÇϱ⠶§¹®¿¡ ÄÄÆ÷³ÍÆ®¿¡ ´ëÇÑ ÀÚ¼¼ÇÑ »çÇ×À» ¼öÁýÇÒ ¶§ ½±°Ô »ç¿ëÇÒ
¼ö ÀÖ´Ù.
´ÙÀ½ÀÇ °£´ÜÇÑ ½ºÅ°¸¶¿¡¼ max/min facet ±âÁØ¿¡ ºÎÇÕÇÏ´Â ¸î °¡Áö À¯ÇüÀ» º¸°Ô µÉ °ÍÀÌ´Ù. ¾î¶²
°ÍÀº ±×·¸Áö ¾ÊÀº °Íµµ ÀÖ´Ù. ( zip
file¿¡ ÀÖ´Â FindTypesMissingFacets.xsd¿¡¼ ¿ÏÀüÇÑ ½ºÅ°¸¶¸¦ ãÀ» ¼ö
ÀÖ´Ù.) Listing 1. »ùÇà ½ºÅ°¸¶
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.research.ibm.com/XML/NS/xsd"
xmlns="http://www.research.ibm.com/XML/NS/xsd">
<!-- SimpleType missing both max/min facets -->
<xsd:simpleType name="integer-noFacets">
<xsd:restriction base="xsd:integer"/>
</xsd:simpleType>
<!-- Derived type has inherited min facet but missing max facet -->
<xsd:simpleType name="positiveInteger-inheritedMinFacet">
<xsd:restriction base="xsd:positiveInteger"/>
</xsd:simpleType>
<!-- Derived type with both effective max/min facets -->
<xsd:simpleType name="positiveInteger-bothFacets">
<xsd:restriction base="positiveInteger-inheritedMinFacet">
<xsd:maxExclusive value="100"/>
</xsd:restriction>
</xsd:simpleType>
<!-- etc... -->
</xsd:schema>
|
½ºÅ°¸¶¸¦ ¶óÀ̺귯¸®¿¡
·ÎµùÇϱ⠶óÀ̺귯¸®°¡ ´Ù¾çÇÑ ¼Ò½º¿¡¼ ½ºÅ°¸¶ °´Ã¼¸¦ ÀÐ°í ¾µ ¼ö ÀÖ´Ù. IBM
WebSphere EMF ResourceSet ÇÁ·¹ÀÓ¿÷À» »ç¿ëÇÏ¿© ½ºÅ°¸¶ ¼¼Æ®¸¦ ½±°Ô ·ÎµùÇÏ´Â ¹æ¹ýÀ»
¼³¸íÇÏ°Ú´Ù. DOM °´Ã¼¿¡ Á÷Á¢ ½ºÅ°¸¶¸¦ ±¸ÇöÇÏ°í DOM °´Ã¼¿¡¼ ½ºÅ°¸¶¸¦ ¹æÃâÇÒ ¼ö ÀÖ´Ù. ¶óÀ̺귯¸®´Â
XSDResourceSet À̶ó´Â Ä¿½ºÅÒ ±¸ÇöÀ» Á¦°øÇϴµ¥ ÀÌ´Â include,
import, redefine¿¡ ÀÇÇØ °ü·ÃµÈ ½ºÅ°¸¶ ¼¼Æ®¸¦ Áö´ÉÀûÀÌ°í ÀÚµ¿ÀûÀ¸·Î ·ÎµùÇÑ´Ù. °ü·Ã ½ºÅ°¸¶µé »çÀÌÀÇ
Ãß»ó °ü°èµµ ÀÌ ¶óÀ̺귯¸®¿¡¼ ¸ðµ¨¸µµÈ´Ù. Listing 2. ½ºÅ°¸¶
·ÎµùÇϱâ
// String variable schemaURL is "FindTypesMissingFacets.xsd" or the URL to your schema
// Create a resource set and load the main schema file into it.
ResourceSet resourceSet = new ResourceSetImpl();
XSDResourceImpl xsdSchemaResource = (XSDResourceImpl)resourceSet.load(schemaURL);
// getResources() returns an iterator over all the resources, therefore, the main resource
// and those that have been included, imported, or redefined.
for (Iterator resources = resourceSet.getResources().iterator();
resources.hasNext(); /* no-op */)
{
// Return the first schema object found, which is the main schema
// loaded from the provided schemaURL
Resource resource = (Resource)resources.next();
if (resource instanceof XSDResourceImpl)
{
XSDResourceImpl xsdResource = (XSDResourceImpl)resource;
// This returns a com.ibm.etools.xsd.XSDSchema object
return xsdResource.getSchema();
}
}
|
°£ÆíÇÑ ½ºÅ°¸¶
Äõ¸®
XSDSchema °´Ã¼°¡ ÀÖÀ¸¹Ç·Î max/min
facetÀÌ ¾ø´Â ¸ðµç À¯ÇüÀ» ã±âÀ§ÇØ À̸¦ Äõ¸®ÇØ¾ß ÇÑ´Ù. ¿ì¼± Æí¸®ÇÑ ¶óÀ̺귯¸® ¸Þ¼Òµå¸¦ »ç¿ëÇÏ¿© ºôÆ®ÀÎ
Á¤¼ö ŸÀÔ¿¡¼ À¯ÃâÇÑ ¸ðµç simpleTypeDefinition À» ºü¸£°Ô ã´Â´Ù.
¶óÀ̺귯¸®°¡ ½ºÅ°¸¶ÀÇ Ãß»ó ÀǹÌÀÇ ¿Ïº®ÇÑ ¸ðµ¨À» Á¦°øÇϱ⠶§¹®¿¡ ¸Å¿ì °£´ÜÇÏ´Ù.
getTypeDefinitions() À» À§ÇØ XSDSchema ¸¦
Äõ¸®ÇÏ°í ±âº» Á¤¼ö ŸÀÔ¿¡¼ »ó¼Ó¹ÞÀº XSDSimpleTypeDefinition ¸¦ À§ÇØ
ÇÊÅ͸µÇÑ´Ù. Listing 3. ±¸Ã¼Àû À¯Çü ¸®½ºÆ® ¾ò±â
// A handy convenience method quickly gets all
// typeDefinitions within the schema
List allTypes = schema.getTypeDefinitions();
ArrayList allIntegerTypes = new ArrayList();
for (Iterator iter = allTypes.iterator();
iter.hasNext(); /* no-op */)
{
XSDTypeDefinition typedef = (XSDTypeDefinition)iter.next();
// Filter out for only simpleTypes...
if ((typedef instanceof XSDSimpleTypeDefinition)
// ... and filter for built-in integer types
// Use a worker method in the very handy sample
// program com.ibm.etools.xsd.util. XSDSchemaQueryTools
&& XSDSchemaQueryTools.isTypeDerivedFrom(typedef,
schema.getSchemaForSchemaNamespace(), "integer"))
{
// The filter found one; save it and continue.
allIntegerTypes.add(typedef);
}
}
|
½ºÅ°¸¶ ÄÄÆ÷³ÍÆ®
¸ðµ¨ W3C ½ºÅ°¸¶ ½ºÆÑ¿¡ Á¤ÀÇµÈ ¸ðµç ÄÄÆ÷³ÍÆ®´Â ¶óÀ̺귯¸®¿¡¼ ÀÚ¼¼ÇÏ°Ô ¸ðµ¨¸µµÈ´Ù.
Á¤¼ö¿¡¼ À¯ÃâÇÑ ¸ðµç XSDSimpleTypeDefinition ÀÇ ¸®½ºÆ®°¡ ÀÖÀ¸¹Ç·Î
max ¶Ç´Â min facetÀÌ ¾ø´Â °Í¿¡µµ ÀÌ ¸®½ºÆ®¸¦ Äõ¸®ÇÒ ¼ö ÀÖ´Ù. ¸®Æ÷Æ®¸¦ ¸¸µé ¼öµµ ÀÖ´Ù.
¶óÀ̺귯¸®°¡ ºü¸¥ °Ë»öÀ» À§ÇØ max/minExclusive ¶Ç´Â max/minInclusive facetÀ»
±×·ìÇÎ ÇÒ ¼ö ÀÖ´Ù´Â °ÍÀ» ±â¾ïÇ϶ó. ¶ÇÇÑ °¢ À¯Çü ¸¶´Ù ÀÚ¼¼ÇÑ ¾×¼¼½º¸¦ Á¦°øÇÑ´Ù. Listing 4. XSDSimpleType ÄÄÆ÷³ÍÆ® Äõ¸®
for (Iterator iter = allIntegerTypes.iterator();
iter.hasNext(); /* no-op */)
{
XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition)iter.next();
// First, exclude any UNION or LIST types, since
// the schema spec says they can't have min/max facets:
// Part 2: Datatypes in:
// '4.1.5 Constraints on Simple Type Definition Schema Components'
if ((XSDVariety.LIST == simpleType.getValueVariety())
|| (XSDVariety.UNION == simpleType.getValueVariety()))
{
// Unions and lists cannot have min/max facets at all,
// so there's no need to report them
continue;
}
// Get the effective max/min facets for each type -
// this includes ones declared in this type or
// ones that are inherited, and so forth
XSDMaxFacet maxFacet = simpleType.getEffectiveMaxFacet();
XSDMinFacet minFacet = simpleType.getEffectiveMinFacet();
// If you don't have the proper ones, report the error.
if ((null == maxFacet) || (null == minFacet))
{
if (simpleType.isSetName())
{
// A component's URI in the library is effectively
// its <target namespace>#<name>
System.out.println("Schema named component: " + simpleType.getURI() );
}
else
{
// It's an anonymous type, so ask the library
// to construct a default 'alias' for it
System.out.println("Schema anonymous component: " + simpleType.getAliasURI() );
}
System.out.print(" is missing these required facets: ");
if (null == maxFacet)
{
System.out.print(" XSDMaxFacet (either inclusive or exclusive) ");
}
if (null == minFacet)
{
System.out.print(" XSDMinFacet (either inclusive or exclusive) ");
}
// You could also report on the facets this type does have like:
// if (minFacet.isExclusive) {
// System.out.println("minFacet.getValue=" + minFacet.getValue());
// }
}
}
|
max/min facetÀÌ ¾ø´Â
À¯Çü ¸î °³ÀÇ Äڵ带 °¡Áö°í ½ºÅ°¸¶¿¡ ´ëÇÑ ¸Å¿ì »ó¼¼ÇÑ Á¤º¸¸¦ ¹ß°ßÇß´Ù. »ùÇà Äڵ带
´Ù¿î·Îµå ÇÏ¿© Á¦°øµÈ ½ºÅ°¸¶ ÆÄÀÏ¿¡ ´ëÇØ ½ÇÇàÇÏ¸é ´ÙÀ½°ú °°Àº ¸®½ºÆ®°¡ ³ª¿Â´Ù: Listing 5. °á°ú
Schema missing max/min facet report on: FindTypesMissingFacets.xsd
Schema named component: http://www.research.ibm.com/XML/NS/xsd#integer-minFacet
is missing these required facets: XSDMaxFacet (either inclusive or exclusive)
Schema named component: http://www.research.ibm.com/XML/NS/xsd#integer-noFacets
is missing these required facets: XSDMaxFacet (either inclusive or exclusive)
XSDMinFacet (either inclusive or exclusive)
Schema named component: http://www.research.ibm.com/XML/NS/xsd#positiveInteger-inheritedMinFacet
is missing these required facets: XSDMaxFacet (either inclusive or exclusive)
|
°á·Ð ¶óÀ̺귯¸®ÀÇ »ó¼¼ÇÑ ½ºÅ°¸¶ ±¸ÇöÀ¸·Î, ÇÊ¿ä·ÎÇÏ´Â
½ºÅ°¸¶ ºÎºÐÀ» Á¤ÇÐÈ÷ ãÀ» ¼ö ÀÖ´Ù´Â °ÍÀ» ¼³¸íÇß´Ù. ÀÌ ¶óÀ̺귯¸®´Â ½ºÅ°¸¶ ÄÄÆ÷³ÍÆ®¿ë ¼¼ÅÍ ¸Þ¼Òµå(setter
method)¸¦ Á¦°øÇÏ¿© »ùÇà Äڵ带 ½±°Ô ¾÷µ¥ÀÌÆ®ÇÏ¿© À¯½ÇµÈ facetÀ» Ãß°¡ÇÏ¿© ¹ß°ßµÈ ¸ðµç À¯ÇüÀ» ÀÚµ¿À¸·Î
°íÄ¥ ¼ö ÀÖ´Ù. ±×¸®°í ¶óÀ̺귯¸®´Â ½ºÅ°¸¶ÀÇ ±¸Ã¼ÀûÀÎ ±¸ÇöÀ» ¸ðµ¨¸µÇϱ⠶§¹®¿¡ ¾÷µ¥ÀÌÆ® µÈ ½ºÅ°¸¶¸¦
.xsd ÆÄÀÏ¿¡ ´Ù½Ã ÀÛ¼ºÇÒ ¼ö ÀÖ´Ù.
»ùÇÃ
ÄÚµå »ùÇà ÇÁ·Î±×·¥ÀÎ,
XSDFindTypesMissingFacets.java ´Â ÀÌ ±ÛÀ» À§ÇÑ Æ¯º°ÇÑ ¿¹Á¦¿´´Ù.
max/min facetÀ» °¡Áö°í Àְųª ±×·¸Áö ¾ÊÀº ¸¹Àº À¯ÇüÀ» Æ÷ÇÔÇÑ
FindTypesMissingFacets.xsd ½ºÅ°¸¶ ¹®¼¸¦ »ç¿ëÇÑ´Ù.
»ùÇà ÇÁ·Î±×·¥°ú zip
file¿¡ ÀÖ´Â .java ÆÄÀÏÀ» ´Ù¿î·Îµå ÇÒ ¼ö ÀÖ´Ù.
Schema Infoset Model°ú ÇÔ²² Á¦°øµÇ´Â ±âŸ ¿©·¯ .java ÆÄÀÏ »ùÇÃÀÇ º¹»çº»Àº ´ÙÀ½°ú
°°´Ù:
XSDSchemaQueryTools.java ´Â ½ºÅ°¸¶ °´Ã¼¿¡ ´ëÇÑ Çâ»óµÈ
Äõ¸®¸¦ ¼öÇàÇÏ´Â ´Ù¸¥ ¹æ½ÄµéÀ» º¸¿©ÁØ´Ù.
XSDSchemaBuildingTools.java : ½ºÅ°¸¶¸¦ ÇÁ·Î±×·¥À¸·Î
±¸ÇöÇÏ´Â Æí¸®ÇÑ ¸Þ¼Òµå Æ÷ÇÔ.
XSDPrototypicalSchema.java : primer
PurchaseOrder sample ½ºÅ°¸¶¸¦ ±¸ÇöÇÏ´Â ¶óÀ̺귯¸® »ç¿ë.
Âü°íÀÚ·á
|