XFactory 클래스
XFactory 클래스가 제공하는 메소드의 빠른 개요입니다. 개별 메소드는 Information Center의 다른 기사에서 자세히 논의됩니다.
XFactory 클래스는 XPath, XQuery 및 XSLT용 실행 파일 작성을 위한 기본 팩토리 클래스입니다. XStaticContext, XDynamicContext, XItemFactory 및 XSequenceTypeFactory 클래스와 같은 다른 클래스와 팩토리의 인스턴스 작성을 위한 방법이기도 합니다. XFactory의 인스턴스는 등록된 스키마 세트도 유지보수하며 유효성 검증 또는 유효성 검증되지 않을 수 있습니다. 유효성 검증 팩토리는 스키마 인식 실행 파일을 생성하며 소스 문서가 처리되기 전에 등록된 스키마 세트에 대해 유효성 검증됩니다. 스타일시트나 표현식의 다른 세트가 다른 세트의 스키마를 필요로 하면, 둘 이상의 XFactory 인스턴스를 사용하여 분리될 수 있습니다. XFactory 인스턴스는 XFactory 클래스에서 정적 newInstance() 메소드를 호출하여 작성될 수 있습니다. 인스턴스는 설정이 안정되는 한 스레드로부터 안전합니다.
XFactory 클래스 사용 예입니다.
// Create a new XFactory
XFactory factory = XFactory.newInstance();
// Create an XPath executable
XPathExecutable executable = factory.prepareXPath("/something/bar[2]");
// Create a new XStaticContext
XStaticContext staticContext = factory.newStaticContext();
// Create an XPath executable that is compiled in backwards
// compatibility mode
staticContext.setXPathCompatibilityMode(XStaticContext.XPATH1_0_BC_COMPATIBILITY);
XPathExecutable bcExecutable = factory.prepareXPath("/something/bar[2]", staticContext);
// Set validating
factory.setValidating(true);
// Register a schema
factory.registerSchema(new StreamSource("myschema.xsd"));
// Create a schema aware XPath executable
staticContext = factory.newStaticContext();
staticContext.declareNamespace("something", "http://myschema/something");
XPathExecutable schemaExecutable =
factory.prepareXPath("/something:something/bar[2] instance of element(bar, something:barType)", staticContext);
// Get the item factory for this XFactory (the two are related
// since the item factory depends on the schemas that are
// registered with XFactory).
XItemFactory itemFactory = factory.getItemFactory();