[
https://issues.apache.org/jira/browse/XERCESJ-1113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13057337#comment-13057337
]
Ishara Karunarathna commented on XERCESJ-1113:
----------------------------------------------
HI Michael ,
I modified xmlDecl(), and validateXmlIDAttribute() methods. And I modified
configurePipeline() method in org.apache.xerces.parsers.XML11Configuration
class to add xml:id handler component to pipe line, here I have posted those
modified methods.
org.apache.xerces.xmlID.XmlIDHandler
public void xmlDecl(String version, String encoding, String standalone,
Augmentations augs)
throws XNIException {
fIsXML11 = "1.1".equals(version);
// call handlers
if (fDocumentHandler != null) {
fDocumentHandler.xmlDecl(version, encoding, standalone, augs);
}
} // xmlDecl(String,String,String)
private void validateXmlIDAttribute(QName element, String attValue,
XMLAttributeDecl attributeDecl) throws XNIException {
configure();
try {
if(fIsXML11){
fValID11.validate(attValue, fValidationState);
}
else{
fValID.validate(attValue, fValidationState);
}
}
catch (InvalidDatatypeValueException ex) {
fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,
ex.getKey(),
ex.getArgs(),
XMLErrorReporter.SEVERITY_ERROR );
}
}
________________________________________________________________________________________________
org.apache.xerces.parsers.XML11Configuration
I added xml:id handler component after the XML Schema validator component.
/** Configures the pipeline. */
protected void configurePipeline() {
if (fCurrentDVFactory != fDatatypeValidatorFactory) {
fCurrentDVFactory = fDatatypeValidatorFactory;
// use XML 1.0 datatype library
setProperty(DATATYPE_VALIDATOR_FACTORY, fCurrentDVFactory);
}
// setup DTD pipeline
if (fCurrentDTDScanner != fDTDScanner) {
fCurrentDTDScanner = fDTDScanner;
setProperty(DTD_SCANNER, fCurrentDTDScanner);
setProperty(DTD_PROCESSOR, fDTDProcessor);
}
fDTDScanner.setDTDHandler(fDTDProcessor);
fDTDProcessor.setDTDSource(fDTDScanner);
fDTDProcessor.setDTDHandler(fDTDHandler);
if (fDTDHandler != null) {
fDTDHandler.setDTDSource(fDTDProcessor);
}
fDTDScanner.setDTDContentModelHandler(fDTDProcessor);
fDTDProcessor.setDTDContentModelSource(fDTDScanner);
fDTDProcessor.setDTDContentModelHandler(fDTDContentModelHandler);
if (fDTDContentModelHandler != null) {
fDTDContentModelHandler.setDTDContentModelSource(fDTDProcessor);
}
// setup document pipeline
if (fFeatures.get(NAMESPACES) == Boolean.TRUE) {
if (fCurrentScanner != fNamespaceScanner) {
fCurrentScanner = fNamespaceScanner;
setProperty(DOCUMENT_SCANNER, fNamespaceScanner);
setProperty(DTD_VALIDATOR, fDTDValidator);
}
fNamespaceScanner.setDTDValidator(fDTDValidator);
fNamespaceScanner.setDocumentHandler(fDTDValidator);
fDTDValidator.setDocumentSource(fNamespaceScanner);
fDTDValidator.setDocumentHandler(fDocumentHandler);
if (fDocumentHandler != null) {
fDocumentHandler.setDocumentSource(fDTDValidator);
}
fLastComponent = fDTDValidator;
} else {
// create components
if (fNonNSScanner == null) {
fNonNSScanner = new XMLDocumentScannerImpl();
fNonNSDTDValidator = new XMLDTDValidator();
// add components
addComponent((XMLComponent) fNonNSScanner);
addComponent((XMLComponent) fNonNSDTDValidator);
}
if (fCurrentScanner != fNonNSScanner) {
fCurrentScanner = fNonNSScanner;
setProperty(DOCUMENT_SCANNER, fNonNSScanner);
setProperty(DTD_VALIDATOR, fNonNSDTDValidator);
}
fNonNSScanner.setDocumentHandler(fNonNSDTDValidator);
fNonNSDTDValidator.setDocumentSource(fNonNSScanner);
fNonNSDTDValidator.setDocumentHandler(fDocumentHandler);
if (fDocumentHandler != null) {
fDocumentHandler.setDocumentSource(fNonNSDTDValidator);
}
fLastComponent = fNonNSDTDValidator;
}
// add XML Schema validator if needed
if (fFeatures.get(XMLSCHEMA_VALIDATION) == Boolean.TRUE) {
// If schema validator was not in the pipeline insert it.
if (fSchemaValidator == null) {
fSchemaValidator = new XMLSchemaValidator();
// add schema component
setProperty(SCHEMA_VALIDATOR, fSchemaValidator);
addCommonComponent(fSchemaValidator);
fSchemaValidator.reset(this);
// add schema message formatter
if
(fErrorReporter.getMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN) == null) {
XSMessageFormatter xmft = new XSMessageFormatter();
fErrorReporter.putMessageFormatter(XSMessageFormatter.SCHEMA_DOMAIN, xmft);
}
}
fLastComponent.setDocumentHandler(fSchemaValidator);
fSchemaValidator.setDocumentSource(fLastComponent);
fSchemaValidator.setDocumentHandler(fDocumentHandler);
if (fDocumentHandler != null) {
fDocumentHandler.setDocumentSource(fSchemaValidator);
}
fLastComponent = fSchemaValidator;
}
// add XML xml:id Handler if needed
if (fFeatures.get(XMLID_HANDLER) == Boolean.TRUE) {
// If xml:id Handler was not in the pipeline insert it.
if (fxmlIDHandler == null) {
fxmlIDHandler = new XmlIDHandler();
// add xmlIDHandler component
setProperty(XMLID_HANDLER, fxmlIDHandler);
addCommonComponent(fxmlIDHandler);
fxmlIDHandler.reset(this);
}
fLastComponent.setDocumentHandler(fxmlIDHandler);
fxmlIDHandler.setDocumentSource(fLastComponent);
fxmlIDHandler.setDocumentHandler(fDocumentHandler);
if (fDocumentHandler != null) {
fDocumentHandler.setDocumentSource(fxmlIDHandler);
}
fLastComponent = fxmlIDHandler;
}
} // configurePipeline()
> [GSoC]: Support for xml:id
> --------------------------
>
> Key: XERCESJ-1113
> URL: https://issues.apache.org/jira/browse/XERCESJ-1113
> Project: Xerces2-J
> Issue Type: New Feature
> Components: XInclude 1.0
> Affects Versions: 2.7.1
> Environment: All
> Reporter: George Cristian Bina
> Labels: gsoc2011
>
> Hi,
> The XInclude ID support should handle xml:id. This is useful for instance
> with DocBook or TEI that use Relax NG schemas for validation and also need
> XInclude support.
> Here it is a patch that adds support for handling xml:id attributes as
> attributes of ID type.
> Index:
> C:/george/workspace/xerces/src/org/apache/xerces/xpointer/ShortHandPointer.java
> ===================================================================
> ---
> C:/george/workspace/xerces/src/org/apache/xerces/xpointer/ShortHandPointer.java
> (revision 344362)
> +++
> C:/george/workspace/xerces/src/org/apache/xerces/xpointer/ShortHandPointer.java
> (working copy)
> @@ -162,6 +162,17 @@
> }
> }
>
> + if (normalizedValue == null && attributes != null) {
> + // Try to see if we can get an xml:id
> + for (int i = 0; i < attributes.getLength(); i++) {
> + if ("xml".equals(attributes.getPrefix(i)) &&
> +
> "id".equals(attributes.getLocalName(i))) {
> + normalizedValue = attributes.getValue(i);
> + break;
> + }
> + }
> + }
> +
> if (normalizedValue != null
> && normalizedValue.equals(fShortHandPointer)) {
> return true;
> Best Regards,
> George
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]