Project

Profile

Help

Bug #4338

closed

Prefixes for default attribute coming from associated XML Schema are no longer output in the output root element

Added by Radu Coravu over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2019-10-11
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

Attaching a set of XML + XSD. At some point in "https://saxonica.plan.io/issues/3068" the issue was fixed but a related problem seems to have appeared again in Saxon 9.9.

The core to reproduce this is something like:

 public static void main(String[] args) throws SAXNotRecognizedException, SAXNotSupportedException, TransformerException {
    File xslFile = new File("test/EXM-35876/copy_stylesheet.xsl");
    InputSource inputSource = new InputSource(xslFile.toURI().toString());
    Source source = new SAXSource(inputSource);
  
    TransformerFactoryImpl transformerFactory = new EnterpriseTransformerFactory();
  
    transformerFactory.getConfiguration().setConfigurationProperty(
        FeatureKeys.SCHEMA_VALIDATION_MODE,
        Validation.toString(Validation.STRICT));
  
    transformerFactory.setAttribute(net.sf.saxon.lib.FeatureKeys.XSLT_SCHEMA_AWARE, true);
    
    Transformer transformer = transformerFactory.newTransformer(source);
  
    // Create XML SAX source
    InputSource inputSource2 = new InputSource(new File("test/EXM-35876/defAttr.xml").toURI().toString());
    SAXSource xmlSource = new SAXSource(inputSource2);
    SAXParser saxParser = new SAXParser();
  
    //EXM-11081 Set this feature so that the default attributes from the schema are reported...
    saxParser.setFeature("http://apache.org/xml/features/validation/schema", true);
    saxParser.setFeature(Constants.SAX_FEATURE_PREFIX + Constants.VALIDATION_FEATURE, true);
    
    xmlSource.setXMLReader(saxParser);
  
    // Output stream result
    File outFile = new File("test/EXM-35876/out.xml");
    if (outFile.exists()) {
      outFile.delete();
    }
    Result outputTarget = new StreamResult(outFile);
    
    // Run transformation
    transformer.transform(xmlSource, outputTarget);
  }

and the output file:

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:gns2="testNS" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="main.xsd" attr1="defVal" DITAArchVersion="defVal"/>

so you can see that in the output both default attributes (attr1 and DITAArchVersion)appear to be in no namespace although both attribute names should be prefixed and in the correct namespace.


Files

EXM-35876.zip (2.28 KB) EXM-35876.zip Radu Coravu, 2019-10-11 07:09

Related issues

Related to Saxon - Bug #4996: Namespace information missing from default XML Schema attribute added by validating XMLReaderClosedMichael Kay2021-05-20

Actions

Please register to edit this issue

Also available in: Atom PDF