Project

Profile

Help

Revision d8f6c896

Added by Michael Kay almost 7 years ago

Fix bug 2210 - concurrent schema import

View differences:

latest9.5/hej/net/sf/saxon/query/QueryParser.java
1149 1149
        // Do the importing
1150 1150

  
1151 1151
        Configuration config = env.getConfiguration();
1152
        if (!config.isSchemaAvailable(sImport.namespaceURI)) {
1153
            if (!sImport.locationURIs.isEmpty()) {
1154
                try {
1155
                    PipelineConfiguration pipe = config.makePipelineConfiguration();
1156
                    config.readMultipleSchemas(pipe, env.getBaseURI(), sImport.locationURIs, sImport.namespaceURI);
1157
                    namespacesToBeSealed.add(sImport.namespaceURI);
1158
                } catch (TransformerConfigurationException err) {
1159
                    grumble("Error in schema " + sImport.namespaceURI + ": " + err.getMessage(), "XQST0059");
1152
        synchronized (config) {
1153
            if (!config.isSchemaAvailable(sImport.namespaceURI)) {
1154
                if (!sImport.locationURIs.isEmpty()) {
1155
                    try {
1156
                        PipelineConfiguration pipe = config.makePipelineConfiguration();
1157
                        config.readMultipleSchemas(pipe, env.getBaseURI(), sImport.locationURIs, sImport.namespaceURI);
1158
                        namespacesToBeSealed.add(sImport.namespaceURI);
1159
                    } catch (TransformerConfigurationException err) {
1160
                        grumble("Error in schema " + sImport.namespaceURI + ": " + err.getMessage(), "XQST0059");
1161
                    }
1162
                } else if (sImport.namespaceURI.equals(NamespaceConstant.XML) ||
1163
                        sImport.namespaceURI.equals(NamespaceConstant.FN) ||
1164
                        sImport.namespaceURI.equals(NamespaceConstant.SCHEMA_INSTANCE)) {
1165
                    config.addSchemaForBuiltInNamespace(sImport.namespaceURI);
1166
                } else {
1167
                    grumble("Unable to locate requested schema " + sImport.namespaceURI, "XQST0059");
1160 1168
                }
1161
            } else if (sImport.namespaceURI.equals(NamespaceConstant.XML) ||
1162
                    sImport.namespaceURI.equals(NamespaceConstant.FN) ||
1163
                    sImport.namespaceURI.equals(NamespaceConstant.SCHEMA_INSTANCE)) {
1164
                config.addSchemaForBuiltInNamespace(sImport.namespaceURI);
1165
            } else {
1166
                grumble("Unable to locate requested schema " + sImport.namespaceURI, "XQST0059");
1167 1169
            }
1170
            ((QueryModule) env).addImportedSchema(sImport.namespaceURI, env.getBaseURI(), sImport.locationURIs);
1168 1171
        }
1169
        ((QueryModule) env).addImportedSchema(sImport.namespaceURI, env.getBaseURI(), sImport.locationURIs);
1170 1172
    }
1171 1173

  
1172 1174
    /**
latest9.5/hej/net/sf/saxon/style/XSLImportSchema.java
84 84
                namespace = namespace.trim();
85 85
            }
86 86
            PreparedStylesheet preparedStylesheet = getPreparedStylesheet();
87
            Configuration config = preparedStylesheet.getConfiguration();
87
            Configuration config = getConfiguration();
88 88
            try {
89 89
                config.checkLicensedFeature(Configuration.LicenseFeature.ENTERPRISE_XSLT, "xsl:import-schema");
90 90
            } catch (LicenseException err) {
......
93 93
                xe.setLocator(this);
94 94
                throw xe;
95 95
            }
96
            AxisIterator kids = iterateAxis(AxisInfo.CHILD);
97
            NodeInfo inlineSchema = null;
98
            while (true) {
99
                Item child = kids.next();
100
                if (child==null) {
101
                    break;
96
            synchronized (config) {   // bug 2210
97
                AxisIterator kids = iterateAxis(AxisInfo.CHILD);
98
                NodeInfo inlineSchema = null;
99
                while (true) {
100
                    Item child = kids.next();
101
                    if (child==null) {
102
                        break;
103
                    }
104
                    if (inlineSchema != null) {
105
                        compileError(getDisplayName() + " must not have more than one child element");
106
                    }
107
                    inlineSchema = (NodeInfo)child;
108
                    if (inlineSchema.getFingerprint() != StandardNames.XS_SCHEMA) {
109
                        compileError("The only child element permitted for " + getDisplayName() + " is xs:schema");
110
                    }
111
                    if (schemaLoc != null) {
112
                        compileError("The schema-location attribute must be absent if an inline schema is present");
113
                    }
114

  
115
                    namespace = config.readInlineSchema(inlineSchema, namespace,
116
                            preparedStylesheet.getCompilerInfo().getErrorListener());
117
                    getPrincipalStylesheetModule().addImportedSchema(namespace);
102 118
                }
103 119
                if (inlineSchema != null) {
104
                    compileError(getDisplayName() + " must not have more than one child element");
105
                }
106
                inlineSchema = (NodeInfo)child;
107
                if (inlineSchema.getFingerprint() != StandardNames.XS_SCHEMA) {
108
                    compileError("The only child element permitted for " + getDisplayName() + " is xs:schema");
120
                    return;
109 121
                }
110
                if (schemaLoc != null) {
111
                    compileError("The schema-location attribute must be absent if an inline schema is present");
122
                if (!config.isSchemaAvailable(namespace)) {
123
                    if (schemaLoc == null) {
124
                        compileWarning("No schema for this namespace is known, " +
125
                                "and no schema-location was supplied, so no schema has been imported",
126
                                SaxonErrorCode.SXWN9006);
127
                        return;
128
                    }
129
                    PipelineConfiguration pipe = config.makePipelineConfiguration();
130
                    namespace = config.readSchema(pipe, getBaseURI(), schemaLoc, namespace);
112 131
                }
113

  
114
                namespace = config.readInlineSchema(inlineSchema, namespace,
115
                        preparedStylesheet.getCompilerInfo().getErrorListener());
116 132
                getPrincipalStylesheetModule().addImportedSchema(namespace);
117 133
            }
118
            if (inlineSchema != null) {
119
                return;
120
            }
121
            if (!config.isSchemaAvailable(namespace)) {
122
                if (schemaLoc == null) {
123
                    compileWarning("No schema for this namespace is known, " +
124
                            "and no schema-location was supplied, so no schema has been imported",
125
                            SaxonErrorCode.SXWN9006);
126
                    return;
127
                }
128
                PipelineConfiguration pipe = config.makePipelineConfiguration();
129
                namespace = config.readSchema(pipe, getBaseURI(), schemaLoc, namespace);
130
            }
131
            getPrincipalStylesheetModule().addImportedSchema(namespace);
132 134
        } catch (SchemaException err) {
133 135
            compileError(err.getMessage(), "XTSE0220");
134 136
        } catch (TransformerConfigurationException err) {

Also available in: Unified diff