You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ws.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2020/01/03 09:57:00 UTC

[jira] [Work logged] (XMLSCHEMA-51) Problem with included schemas with attribute group references

     [ https://issues.apache.org/jira/browse/XMLSCHEMA-51?focusedWorklogId=365777&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-365777 ]

ASF GitHub Bot logged work on XMLSCHEMA-51:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 03/Jan/20 09:56
            Start Date: 03/Jan/20 09:56
    Worklog Time Spent: 10m 
      Work Description: fmoussallam commented on pull request #1: XMLSCHEMA-51 Problem with included schemas with attribute group refer…
URL: https://github.com/apache/ws-xmlschema/pull/1
 
 
   **What is the problem:** The schema builder constructs list of references for Groups, Unions or Lists. These references are qualified names (QName) that correspond to Type definitions elsewhere in the XML Schema. An issue arises if the member of the union or the group are declared in an XSD that does not have a target namespace and that XSD is included in a root XSD which itself has a target namspace. What should happen in that situation is that all elements from the included XSD should inherit the root target namespace. The issue is that the code that creates such QNames today only takes into consideration the direct XSD parent element and ends up creating QNames with empty namespaces. At the end of the build, the schema is inconsistent because Groups and Unions have references with an empty namespace while the actual element referenced has a namespace.
   
   **What is the solution:** When a reference is created, if it ends up being unqualified, check for the possibility that the current XSD has no namespace but is included in a root XSD that has a namespace. In that case, use the root target namespace.
   
   Note that this is not a perfect solution as there is still a possibility that a member of a union for instance should have an empty namespace. We consider this to be unlikely though and should happen way less often then included XSD without namespace;
   
   A better solution in the long run would be to have a second pass at the end of the build to reconnect references to actual types.
 
----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

            Worklog Id:     (was: 365777)
    Remaining Estimate: 0h
            Time Spent: 10m

> Problem with included schemas with attribute group references
> -------------------------------------------------------------
>
>                 Key: XMLSCHEMA-51
>                 URL: https://issues.apache.org/jira/browse/XMLSCHEMA-51
>             Project: XmlSchema
>          Issue Type: Question
>            Reporter: Fady Moussallam
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hello,
> I am using version 2.2.3.
> I have a problem with a combination of included schemas and attribute group references.
> Say you have schemaA including schemaB. schemaB does not have a default namespace, nor a target namespace, since it is meant to be included. It therefore inherits the namespace of the including schema (in this case schemaA).
> The problem arises if schemaB contains markup like this:
> {code}
> <xs:attributeGroup ref="QuantityGroup"/>
>  ...
>  </xs:attributeGroup>
> {code}
> In org.apache.ws.commons.schema.SchemaBuilder#handleAttributeGroupRef the reference QName is obtained with the getRefQName(String pName, Node pNode) method.
> In this method, the namespace is derived using the NodeNamespaceContext.getNamespaceContext(pNode) method. This one in turn determines available namespaces directly from the DOM using PrefixCollector.searchAllPrefixDeclarations(pNode).
> Problem is that from a DOM standpoint schemaB does not contain any namespace declarations. So the reference QName end up having no namespace.
> This seems wrong and creates problems when later on you want to find the referenced group using XmlSchemaCollection#getAttributeGroupByName(QName name) which returns null.
> I can fix my issue in SchemaBuilder#getRefQName by doing this:
> {code}
> ...
> if (offset == -1) {
>  uri = pContext.getNamespaceURI(Constants.DEFAULT_NS_PREFIX);
>  if (Constants.NULL_NS_URI.equals(uri)) {
>  if (currentSchema.getLogicalTargetNamespace().isEmpty()) {
>  return new QName(Constants.NULL_NS_URI, pName);
>  } else {
>  return new QName(currentSchema.getLogicalTargetNamespace(), pName);
>  }
>  }
>  localName = pName;
>  prefix = Constants.DEFAULT_NS_PREFIX;
>  } else {
> ...
> {code}
> But I am not sure if there are any side effects.
> Any opinion or advice on this would be very appreciated.
> Thank you
>  
> Fady
>  
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ws.apache.org
For additional commands, e-mail: dev-help@ws.apache.org