You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@daffodil.apache.org by "shanedell (via GitHub)" <gi...@apache.org> on 2024/03/01 01:15:25 UTC
[I] Root element and namespace auto suggestions/finding [daffodil-vscode]
shanedell opened a new issue, #984:
URL: https://github.com/apache/daffodil-vscode/issues/984
As of right now when debugging a schema the user needs to know if a root element name or namespace needs set. It would be nice to have some features where either the extension or the debugger or both can let the user know, what possible root element names or namespaces could be used for the specific schema. For example, with the DFDL envelopePayload schema @mbeckerle created, if the `rootName` is not set the debugger, extension or both will let the user know that the schema may fail to debug if the `rootName` is not set to values one of [`a`, `b`, ...].
--
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: commits-unsubscribe@daffodil.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Root element and namespace auto suggestions/finding [daffodil-vscode]
Posted by "shanedell (via GitHub)" <gi...@apache.org>.
shanedell closed issue #984: Root element and namespace auto suggestions/finding
URL: https://github.com/apache/daffodil-vscode/issues/984
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Root element and namespace auto suggestions/finding [daffodil-vscode]
Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on issue #984:
URL: https://github.com/apache/daffodil-vscode/issues/984#issuecomment-2659966463
Feels a bit fragile to me. Though most of the DFDL schemas I've seen and written do use the two space indentation convention, it's definitely not required and there some exceptions.
If the feature you're looking for would be in java/scala code, it's not too hard to get all global elements with the Scala XML library (which is a transitive dependency of Daffodil so it should be on the classpath). It would be something like:
```scala
val globalElementNames = (scala.xml.XML.load("path/to/file.dfdl.xsd")) \ "element").map(_ \@ "name")
```
That returns a `Seq[String]` of the names of global elements in the schema.
I bet there's a library available in npm with similar XML query capabilities if you need it in the javascript code, maybe even built in to javascript.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Root element and namespace auto suggestions/finding [daffodil-vscode]
Posted by "stevedlawrence (via GitHub)" <gi...@apache.org>.
stevedlawrence commented on issue #984:
URL: https://github.com/apache/daffodil-vscode/issues/984#issuecomment-1973537360
Daffodil doesn't really have a way good way to query for all global elements. You could potentially create `ProcessorFactory` without specifying a root name/namespace (e.g. `Compiler.compileFile("path/to/schema.dfdl.xsdf")`, and then query members of its `SchemaSet` to find all possible global element declarations and their namespace, similar to this:
https://github.com/apache/daffodil/blob/main/daffodil-core/src/main/scala/org/apache/daffodil/core/dsom/SchemaSet.scala#L380-L382
But that's diving pretty deep into the Daffodil internals and probably isn't recommended.
Probably the easiest approach is to just scan the main schema for global element declarations yourself (e.g. find `xs:element`'s that are immediate children of the `xs:schema`, and suggest those as possible roots. And the suggested namespace is just the `targetNmespace` property.
Technically the root element could come from any included/imported schema, but that's pretty uncommon--the root almost always comes from the primary schema. And you probably wouldn't want to suggest all those imported global element declarations anyways because there are often a bunch of them them and it would just be confusing to users.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Root element and namespace auto suggestions/finding [daffodil-vscode]
Posted by "shanedell (via GitHub)" <gi...@apache.org>.
shanedell closed issue #984: Root element and namespace auto suggestions/finding
URL: https://github.com/apache/daffodil-vscode/issues/984
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Root element and namespace auto suggestions/finding [daffodil-vscode]
Posted by "shanedell (via GitHub)" <gi...@apache.org>.
shanedell commented on issue #984:
URL: https://github.com/apache/daffodil-vscode/issues/984#issuecomment-2659929598
@stevedlawrence @mbeckerle For finding the main global element declarations to suggest to the user, would it be okay to look for only two spaces for the declaration? Since those would be the ones directly under the schema I figured this would be the main way to filter other global elements.
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] Root element and namespace auto suggestions/finding [daffodil-vscode]
Posted by "shanedell (via GitHub)" <gi...@apache.org>.
shanedell commented on issue #984:
URL: https://github.com/apache/daffodil-vscode/issues/984#issuecomment-1973493630
@stevedlawrence @mbeckerle Does this sound like something may be achievable in a general sense and in the sense of is there anything in Daffodil that may do something similar or help with this?
--
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: commits-unsubscribe@daffodil.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org