XML Schema clean up tool
Are you missing a feature? Request its implementation here.
-
- Posts: 12
- Joined: Sun Dec 14, 2008 2:17 pm
XML Schema clean up tool
I would like to suggest hereby that you develop a tool which removes unused types from an XML schema. One specific use case in which I need such tool badly is XML schema flattening. I do that a lot but resulting schema files turn out to be up to 5 times bigger than schemas flattened with other (than oXyten XML) tools. The reason for that is that oXygen flattening tool crams into generated flattened schema all types from all included schemas regardless of whether the types are really used or not in the generated schema. A schema clean up tool could solve this problem and it could also be valuable general purpose tool too.
Regards
Nikolay
Regards
Nikolay
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: XML Schema clean up tool
Post by sorin_ristache »
Hello,
Thank you for your suggestion. We will consider implementing an XML Schema clean up tool in a future version of Oxygen.
Thank you,
Sorin
Thank you for your suggestion. We will consider implementing an XML Schema clean up tool in a future version of Oxygen.
Thank you,
Sorin
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XML Schema clean up tool
Hello,
Right now, it is scheduled for 13.x, but this might change. I've increased its priority a notch.
Regards,
Adrian
Right now, it is scheduled for 13.x, but this might change. I've increased its priority a notch.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 97
- Joined: Tue Apr 22, 2008 9:31 am
Re: XML Schema clean up tool
I would also find an XML Schema clean up tool useful. But I think used in a slightly different way to Nikolay
We currently have an in-house tool that takes for its input a master XML schema and a group of XML files. From this input, the tool generates a sub XML schema with only the schema types matched from the input XML files. We have options to include the complete XML schema type or, more often, remove the superfluous elements and attributes from each type not found in any of the input XML files.
The master XML file was generated from a model as the super set of our service messages and the sub XML schemas are used in per message schema validation.
We currently have an in-house tool that takes for its input a master XML schema and a group of XML files. From this input, the tool generates a sub XML schema with only the schema types matched from the input XML files. We have options to include the complete XML schema type or, more often, remove the superfluous elements and attributes from each type not found in any of the input XML files.
The master XML file was generated from a model as the super set of our service messages and the sub XML schemas are used in per message schema validation.
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XML Schema clean up tool
@csalsa:
Thank you for the feedback.
I've added your comments to our issue tracking tool and your use case will be taken under consideration when this feature gets implemented.
Regards,
Adrian
Thank you for the feedback.
I've added your comments to our issue tracking tool and your use case will be taken under consideration when this feature gets implemented.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 7
- Joined: Mon Feb 18, 2008 7:49 pm
Re: XML Schema clean up tool
I would use that feature too, it would, of course need to support imported modules etc.
for now I run the following XPath:
//xs:complexType[not(./@name = //xs:element/@type)]
(which coincidentally detects anonymous types too, which we don't want in our schemas due to design patterns)
for now I run the following XPath:
//xs:complexType[not(./@name = //xs:element/@type)]
(which coincidentally detects anonymous types too, which we don't want in our schemas due to design patterns)
-
- Posts: 407
- Joined: Mon Dec 05, 2011 6:08 pm
Re: XML Schema clean up tool
Hi Nikolay,
Currently, this feature is scheduled to be implemented in v15, but this is not fixed, so it could be pushed further back.
Regards,
Ionela
Currently, this feature is scheduled to be implemented in v15, but this is not fixed, so it could be pushed further back.
Regards,
Ionela
Ionela Istodor
oXygen XML Editor and Author Support
oXygen XML Editor and Author Support
-
- Posts: 12
- Joined: Sun Dec 14, 2008 2:17 pm
Re: XML Schema clean up tool
Oh, well... I am giving this up. It is taking way too long.

For the benefit of everybody interisted in the matter, I am including below
an xquery script which I am currently using for the purpose of cleaning up
flattened schemas.


For the benefit of everybody interisted in the matter, I am including below
an xquery script which I am currently using for the purpose of cleaning up
flattened schemas.
Code: Select all
(:===========================================================================
Copyright(©) 2013 Nikolay Ognyanov
Licensed 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.
=============================================================================
clean_xsd.xq :
An xquery script which removes unused types from an xml schema.
Should be applied only to flattened schemas!
===========================================================================:)
xquery version "3.0";
(:=========================================================================:)
(: 3.0 is needed for namespace constructors. XML schemas generally need :)
(: "xmlns=..." even though all elements are in the xs: namespace because :)
(: everything referenced in schemas must have namespace including e.g. :)
(: type names which only appear within strings. :)
(:=========================================================================:)
declare function local:unused-types(
$target as element()*,
$types as element()*,
$unusedTypes as element()*
)
as element()*
{
let
$newTarget := $target except $unusedTypes,
$moreUnusedTypes := $types[
not(
(./@name = $newTarget/@type )
or
(./@name = $newTarget//xs:element/@type )
or
(./@name = $newTarget//xs:attribute/@type )
or
(./@name = $newTarget//xs:restriction/@base )
or
(./@name = $newTarget//xs:extension/@base )
or
(./@name = $newTarget//xs:list/@itemType )
or
(./@name = $newTarget//xs:attributeGroup/@ref)
or
(
some $mt in $newTarget//xs:union/@memberTypes
satisfies contains(string($mt), string(./@name))
)
)
],
$newUnusedTypes := $moreUnusedTypes except $unusedTypes
return
if(empty($newUnusedTypes))
then
$unusedTypes
else
local:unused-types($newTarget, $types, $moreUnusedTypes)
};
(:=========================================================================:)
declare function local:remove-unused-types(
$target as node()*,
$blackList as element()*,
$skipAnnotations as xs:boolean
)
as node()*
{
for $node in $target
return
if ($node instance of document-node())
then
document {
local:remove-unused-types(
$node/node(), $blackList, $skipAnnotations)
}
else if ($node instance of element())
then
if(some $n in $blackList satisfies $n is $node)
then
()
else
if(string(node-name($node)) = "xs:annotation"
and $skipAnnotations)
then
()
else
element { node-name($node)} {
$node/@*,
if($node/.. instance of document-node())
then
in-scope-prefixes($node)!
namespace{.}
{namespace-uri-for-prefix(.,$node)}
else
(),
local:remove-unused-types(
$node/node(), $blackList, $skipAnnotations)
}
else
$node
} ;
(:=========================================================================:)
declare function local:clean-xsd(
$xsd as document-node(),
$skipAnnotations as xs:boolean
)
as document-node()
{
let
$topTypes :=
$xsd/xs:schema/xs:attributeGroup |
$xsd/xs:schema/xs:simpleType |
$xsd/xs:schema/xs:complexType,
$unusedTypes :=
local:unused-types($xsd/xs:schema/*, $topTypes, ())
return
local:remove-unused-types($xsd, $unusedTypes, $skipAnnotations)
};
(:=========================================================================:)
local:clean-xsd(/, false())
(:=========================================================================:)
-
- Posts: 2
- Joined: Wed Mar 04, 2015 2:13 pm
Re: XML Schema clean up tool
Post by RampantBadger »
any news on this as trialling oxygen developer at the moment in v16.1 and this is an important feature for me
-
- Posts: 2
- Joined: Wed Mar 04, 2015 2:13 pm
Re: XML Schema clean up tool
Post by RampantBadger »
unfortunately the xml query script supplied here removes some of my used entries as well as unused ones
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XML Schema clean up tool
Hi,
@RampantBadger: I'm afraid that the status has not changed for this feature request. It's still pending and remains to be scheduled.
Regards,
Adrian
@RampantBadger: I'm afraid that the status has not changed for this feature request. It's still pending and remains to be scheduled.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service