You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ppkarwasz (via GitHub)" <gi...@apache.org> on 2023/12/20 20:35:14 UTC

[PR] Add an XML schema generator [logging-log4j-tools]

ppkarwasz opened a new pull request, #92:
URL: https://github.com/apache/logging-log4j-tools/pull/92

   Adds an XML schema generator that uses an XML metadata file as input (cf. `log4j-docgen/src/test/resources/META-INF/log4j/plugins-sample.xml` as example) and output an XML schema.
   
   ## Tips for the reviewers
   
   An example of generated XML schema is in `log4j-docgen/src/test/resources/expected/xsd/log4j-config.xsd`. It describes a minimal set of Log4j plugins. You can peruse it in an IDE to see if in needs some changes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add an XML schema generator [logging-log4j-tools]

Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #92:
URL: https://github.com/apache/logging-log4j-tools/pull/92#discussion_r1442794428


##########
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java:
##########
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.docgen.internal;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.logging.log4j.docgen.AbstractType;
+import org.apache.logging.log4j.docgen.Description;
+import org.apache.logging.log4j.docgen.PluginAttribute;
+import org.apache.logging.log4j.docgen.PluginElement;
+import org.apache.logging.log4j.docgen.PluginSet;
+import org.apache.logging.log4j.docgen.PluginType;
+import org.apache.logging.log4j.docgen.ScalarType;
+import org.apache.logging.log4j.docgen.ScalarValue;
+import org.apache.logging.log4j.docgen.Type;
+import org.apache.logging.log4j.docgen.io.stax.PluginBundleStaxReader;
+import org.apache.logging.log4j.docgen.util.TypeLookup;
+import org.apache.logging.log4j.docgen.xsd.SchemaGenerator;
+import org.apache.logging.log4j.docgen.xsd.SchemaGeneratorRequest;
+
+@Singleton
+@Named("default")
+public class DefaultSchemaGenerator implements SchemaGenerator {
+
+    private static final String LOG4J_PREFIX = "log4j";
+    private static final String LOG4J_NAMESPACE = "http://logging.apache.org/log4j/2.0/config";

Review Comment:
   I liked the `http://logging.apache.org/xml/ns/config` idea. I would appreciate it if you can implement that change and resolve this conversation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add an XML schema generator [logging-log4j-tools]

Posted by "vy (via GitHub)" <gi...@apache.org>.
vy commented on code in PR #92:
URL: https://github.com/apache/logging-log4j-tools/pull/92#discussion_r1434136488


##########
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java:
##########
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.docgen.internal;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.logging.log4j.docgen.AbstractType;
+import org.apache.logging.log4j.docgen.Description;
+import org.apache.logging.log4j.docgen.PluginAttribute;
+import org.apache.logging.log4j.docgen.PluginElement;
+import org.apache.logging.log4j.docgen.PluginSet;
+import org.apache.logging.log4j.docgen.PluginType;
+import org.apache.logging.log4j.docgen.ScalarType;
+import org.apache.logging.log4j.docgen.ScalarValue;
+import org.apache.logging.log4j.docgen.Type;
+import org.apache.logging.log4j.docgen.io.stax.PluginBundleStaxReader;
+import org.apache.logging.log4j.docgen.util.TypeLookup;
+import org.apache.logging.log4j.docgen.xsd.SchemaGenerator;
+import org.apache.logging.log4j.docgen.xsd.SchemaGeneratorRequest;
+
+@Singleton
+@Named("default")
+public class DefaultSchemaGenerator implements SchemaGenerator {
+
+    private static final String LOG4J_PREFIX = "log4j";
+    private static final String LOG4J_NAMESPACE = "http://logging.apache.org/log4j/2.0/config";

Review Comment:
   Shouldn't this rather be `.../2.x/...`? (I am not sure either...)



##########
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/util/TypeLookup.java:
##########


Review Comment:
   This class has 3 unused variables. See my remarks in #93.



##########
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/xsd/package-info.java:
##########
@@ -0,0 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+@Export

Review Comment:
   ```suggestion
   // This directory is effectively not empty!
   // We `@Export` schema generators that will be auto-generated by Modello under this package path.
   // See `packageName` elements in `plugins-model.xml` for details.
   @Export
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add an XML schema generator [logging-log4j-tools]

Posted by "jvz (via GitHub)" <gi...@apache.org>.
jvz commented on code in PR #92:
URL: https://github.com/apache/logging-log4j-tools/pull/92#discussion_r1438396146


##########
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java:
##########
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.docgen.internal;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.logging.log4j.docgen.AbstractType;
+import org.apache.logging.log4j.docgen.Description;
+import org.apache.logging.log4j.docgen.PluginAttribute;
+import org.apache.logging.log4j.docgen.PluginElement;
+import org.apache.logging.log4j.docgen.PluginSet;
+import org.apache.logging.log4j.docgen.PluginType;
+import org.apache.logging.log4j.docgen.ScalarType;
+import org.apache.logging.log4j.docgen.ScalarValue;
+import org.apache.logging.log4j.docgen.Type;
+import org.apache.logging.log4j.docgen.io.stax.PluginBundleStaxReader;
+import org.apache.logging.log4j.docgen.util.TypeLookup;
+import org.apache.logging.log4j.docgen.xsd.SchemaGenerator;
+import org.apache.logging.log4j.docgen.xsd.SchemaGeneratorRequest;
+
+@Singleton
+@Named("default")
+public class DefaultSchemaGenerator implements SchemaGenerator {
+
+    private static final String LOG4J_PREFIX = "log4j";
+    private static final String LOG4J_NAMESPACE = "http://logging.apache.org/log4j/2.0/config";

Review Comment:
   Depends on the release version. As the site layout is now, `2.x` is a symlink to the latest release. If we have multiple schema versions published, they should have different versions in the URL somewhere.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add an XML schema generator [logging-log4j-tools]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #92:
URL: https://github.com/apache/logging-log4j-tools/pull/92#discussion_r1438403633


##########
log4j-docgen/src/main/java/org/apache/logging/log4j/docgen/internal/DefaultSchemaGenerator.java:
##########
@@ -0,0 +1,306 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.docgen.internal;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import javax.inject.Named;
+import javax.inject.Singleton;
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+import org.apache.logging.log4j.docgen.AbstractType;
+import org.apache.logging.log4j.docgen.Description;
+import org.apache.logging.log4j.docgen.PluginAttribute;
+import org.apache.logging.log4j.docgen.PluginElement;
+import org.apache.logging.log4j.docgen.PluginSet;
+import org.apache.logging.log4j.docgen.PluginType;
+import org.apache.logging.log4j.docgen.ScalarType;
+import org.apache.logging.log4j.docgen.ScalarValue;
+import org.apache.logging.log4j.docgen.Type;
+import org.apache.logging.log4j.docgen.io.stax.PluginBundleStaxReader;
+import org.apache.logging.log4j.docgen.util.TypeLookup;
+import org.apache.logging.log4j.docgen.xsd.SchemaGenerator;
+import org.apache.logging.log4j.docgen.xsd.SchemaGeneratorRequest;
+
+@Singleton
+@Named("default")
+public class DefaultSchemaGenerator implements SchemaGenerator {
+
+    private static final String LOG4J_PREFIX = "log4j";
+    private static final String LOG4J_NAMESPACE = "http://logging.apache.org/log4j/2.0/config";

Review Comment:
   Among the XML namespaces I know there are two schools:
   
   - [Java EE](http://www.oracle.com/webfolder/technetwork/jsc/xml/ns/javaee/index.html), [Jakarta EE](https://jakarta.ee/xml/ns/jakartaee/) and [Spring](http://www.springframework.org/schema/) do not have a version number in the namespace; they have a `version` attribute on the main
   - [Maven](https://maven.apache.org/xsd/) has a version number in the namespace, but the XSDs are at `https://maven.apache.org/xsd/`.
   
   In every case, the version number is in the filename. I would use some neutral namespace like `http://logging.apache.org/xml/ns/config`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add an XML schema generator [logging-log4j-tools]

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #92:
URL: https://github.com/apache/logging-log4j-tools/pull/92


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org