From 4a8510fb02c854c460fb44f9ad8dc5565c986fb7 Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Tue, 31 May 2022 10:49:54 +0200 Subject: [PATCH] Introduce XSD support --- .../OSGI-INF/maintenanceService.xml | 1 + .../org/argeo/app/core/SuiteContentTypes.java | 56 + .../app/core/SuiteMaintenanceService.java | 19 +- .../src/org/argeo/app/core/schemas/fop.xsd | 4313 +++++++++++++++++ .../app/core/schemas/xCal-2.0-RFC6321.rnc | 1192 +++++ .../org/argeo/app/core/schemas/xCal-2.0.rnc | 1207 +++++ .../org/argeo/app/core/schemas/xCal-2.0.xsd | 1489 ++++++ .../app/core/schemas/xCard-4.0-RFC6351.rnc | 382 ++ .../org/argeo/app/core/schemas/xCard-4.0.rnc | 385 ++ .../org/argeo/app/core/schemas/xCard-4.0.xsd | 1041 ++++ 10 files changed, 10084 insertions(+), 1 deletion(-) create mode 100644 org.argeo.app.core/src/org/argeo/app/core/SuiteContentTypes.java create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/fop.xsd create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/xCal-2.0-RFC6321.rnc create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/xCal-2.0.rnc create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/xCal-2.0.xsd create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/xCard-4.0-RFC6351.rnc create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/xCard-4.0.rnc create mode 100644 org.argeo.app.core/src/org/argeo/app/core/schemas/xCard-4.0.xsd diff --git a/org.argeo.app.core/OSGI-INF/maintenanceService.xml b/org.argeo.app.core/OSGI-INF/maintenanceService.xml index b88d68c..7ebc97b 100644 --- a/org.argeo.app.core/OSGI-INF/maintenanceService.xml +++ b/org.argeo.app.core/OSGI-INF/maintenanceService.xml @@ -4,4 +4,5 @@ + diff --git a/org.argeo.app.core/src/org/argeo/app/core/SuiteContentTypes.java b/org.argeo.app.core/src/org/argeo/app/core/SuiteContentTypes.java new file mode 100644 index 0000000..3c8b5d8 --- /dev/null +++ b/org.argeo.app.core/src/org/argeo/app/core/SuiteContentTypes.java @@ -0,0 +1,56 @@ +package org.argeo.app.core; + +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Objects; + +public enum SuiteContentTypes { + // + XCARD_4_0("xcard", "urn:ietf:params:xml:ns:vcard-4.0", "xCard-4.0.xsd", null), + // + XSL_FO_1999("fo", "http://www.w3.org/1999/XSL/Format", "fop.xsd", + "https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/fop/src/foschema/fop.xsd"), + // +// XCAL_2_0("xcal", "urn:ietf:params:xml:ns:icalendar-2.0", "xCal-2.0.xsd", null), + // + ; + + private final static String RESOURCE_BASE = "/org/argeo/app/core/schemas/"; + + private String defaultPrefix; + private String namespace; + private URL resource; + private URL publicUrl; + + SuiteContentTypes(String defaultPrefix, String namespace, String resourceFileName, String publicUrl) { + Objects.requireNonNull(namespace); + this.defaultPrefix = defaultPrefix; + Objects.requireNonNull(namespace); + this.namespace = namespace; + resource = getClass().getResource(RESOURCE_BASE + resourceFileName); + Objects.requireNonNull(resource); + if (publicUrl != null) + try { + this.publicUrl = new URL(publicUrl); + } catch (MalformedURLException e) { + throw new IllegalArgumentException("Cannot interpret public URL", e); + } + } + + public String getDefaultPrefix() { + return defaultPrefix; + } + + public String getNamespace() { + return namespace; + } + + public URL getResource() { + return resource; + } + + public URL getPublicUrl() { + return publicUrl; + } + +} diff --git a/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenanceService.java b/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenanceService.java index 532b7dd..ce90a87 100644 --- a/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenanceService.java +++ b/org.argeo.app.core/src/org/argeo/app/core/SuiteMaintenanceService.java @@ -8,6 +8,7 @@ import javax.jcr.Session; import javax.jcr.nodetype.NodeType; import javax.jcr.security.Privilege; +import org.argeo.api.acr.spi.ProvidedRepository; import org.argeo.api.cms.CmsConstants; import org.argeo.app.api.EntityType; import org.argeo.jcr.JcrUtils; @@ -15,6 +16,17 @@ import org.argeo.maintenance.AbstractMaintenanceService; /** Initialises an Argeo Suite backend. */ public class SuiteMaintenanceService extends AbstractMaintenanceService { + private ProvidedRepository contentRepository; + + @Override + public void init() { + super.init(); + + for (SuiteContentTypes types : SuiteContentTypes.values()) { + contentRepository.registerTypes(types.getDefaultPrefix(), types.getNamespace(), + types.getResource().toExternalForm()); + } + } @Override public boolean prepareJcrTree(Session adminSession) throws RepositoryException, IOException { @@ -33,7 +45,12 @@ public class SuiteMaintenanceService extends AbstractMaintenanceService { public void configurePrivileges(Session adminSession) throws RepositoryException { JcrUtils.addPrivilege(adminSession, EntityType.user.basePath(), CmsConstants.ROLE_USER_ADMIN, Privilege.JCR_ALL); - //JcrUtils.addPrivilege(adminSession, "/", SuiteRole.coworker.dn(), Privilege.JCR_READ); + // JcrUtils.addPrivilege(adminSession, "/", SuiteRole.coworker.dn(), + // Privilege.JCR_READ); + } + + public void setContentRepository(ProvidedRepository contentRepository) { + this.contentRepository = contentRepository; } } diff --git a/org.argeo.app.core/src/org/argeo/app/core/schemas/fop.xsd b/org.argeo.app.core/src/org/argeo/app/core/schemas/fop.xsd new file mode 100644 index 0000000..a787bf3 --- /dev/null +++ b/org.argeo.app.core/src/org/argeo/app/core/schemas/fop.xsd @@ -0,0 +1,4313 @@ + + + + + + + + + I'm not sure where to place this. + It applies to the page context (NOT implemented) + + + I have not coded for the functions described in 5.10 Core Function Library + They need to be segregated into groups and then inserted in the types + + common_functions + object inherited-property-value(NCName) + object from-parent( NCName) + object from-nearest-specified-value( NCName) + object merge-property-values( NCName) + + font_functions + object system-font( NCName , NCName) + + length_functions + numeric floor( numeric) + numeric ceiling(numeric) + numeric round(numeric) + numeric min( numeric , numeric) + numeric max(numeric , numeric) + numeric abs( numeric) + + table_cell_or_descendants_functions + object from-table-column( NCName) + + color_functions + color rgb(numeric , numeric , numeric) + color rgb-icc(numeric , numeric , numeric , NCName , numeric , numeric) + color system-color( NCName) + + label_functions + numeric body-start() + numeric label-end() + + (defined) + table-column_functions + numeric proportional-column-width( numeric) + + This schema has been developed in order to validate XSL FO documents for FOP + All of the elements need to be prefixed with fo: + The namespace prefix is xmlns:fo = "http://www.w3.org/1999/XSL/Format". + + This schema, as delivered, may either validate the full spec, or, just the FOP portion. + (What it validates depends upon what I was doing with it when released.) + + If you want to restrict it to just those elements and attributes implemented by FOP, + you need to edit the and tags to exclude the groups ending with _Not + + Some schema tools complain about the placement of comments in this schema and will remove or reorder them + There are fop_result and fop_fail comments on specific features not implemented by FOP + + FOP does not enforce the following schema requirements + + fo:simple-page-master model = "(region-body,region-before?,region-after?,region-start?,region-end?)" + elements can be in any order + + fo:table-cell model = "(%block;)+" + Can be empty + + fo:flow model = "(%block;)+" + Can be empty + + This schema allows the length attribute to be negative for some elements like margins. + There may be instances where I've entered %integer_Type; and it should be positive-integer or number + The schema trys to handle the text based rules re: fo:markers, fo:float, footer and fo:initial-property-set + But, allows you to do illegal things if you want because I couldn't figure out how to constrain against the illegal actions. + + Please e-mail your comments to cpaussa@myrealbox.com + + Contribution by Oleg Tkachenko + (Declarations able to include non-xsl children) + + This declaration assumes that all elements must come before other stuff, + which is not required by spec, but I cannot see any way to express such constraints in schema, + one could use instead of , but this way we lose control over (color-profile)+ constraint. + + VCP 21-Oct-2002 + Updated all (px|pt|mm|cm|in|em) to (px|pt|mm|cm|in|em|%) to allow percentage types. + Updated the restriction base of those types from NMTOKEN to string + + + + + + + + + + + + + empty group so cannot be defined + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + empty group so cannot be defined + + + + + + + + + + + + + + empty group + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Removed because I'm not sure how to handle this + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Inheritable + + + + + + + + + + + + + + + + + + + + + + + + + + Inheritable + + + + + + + + + + + + + + + + Inheritable + + + + + + + + + + + + + + + + + Inheritable + + + + + + + + + + + + + + Inheritable attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Inherited + + + + + + + + + + + + + + + + + + + + + + Inherited + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Inherited + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Font properties are all inheritable + + + + + + + + + + + Font properties are all inheritable + + + + + + + + + + + + + + + + The hyphenation properties are all inheritable and so superceeded by that list + + + + + + + + + + + + + The hyphenation properties are all inheritable and so superceeded by that list + + + + + + + + + + + + + + + + + + Indent properties are inheritable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Simple Types definitions + + + + + + A signed integer value which consists of an optional '+' or '-' character followed by a sequence of digits. A property may define additional constraints on the value. + + + + + + + + + + + + + + + A signed real number which consists of an optional '+' or '-' character followed by a sequence of digits followed by an optional '.' character and sequence of digits. A property may define additional constraints on the value. + + + + + + + + + + + + + A signed length value where a 'length' is a real number plus a unit qualification. A property may define additional constraints on the value. + + + + + + + + + + + + + + + + A compound datatype, with components: minimum, optimum, maximum. Each component is a . If "minimum" is greater than optimum, it will be treated as if it had been set to "optimum". If "maximum" is less than optimum, it will be treated as if it had been set to "optimum". A property may define additional constraints on the values. + + + + + + + + + + + + + + + + + + + + + A compound datatype, with components: length, conditionality. The length component is a . The conditionality component is either "discard" or "retain". A property may define additional constraints on the values. + + + + + + + + + + + + + + + + + + + + + + + + A compound datatype, with components: block-progression-direction, and inline-progression-direction. Each component is a . A property may define additional constraints on the values. + + + + + + + + + + + + + + + + + + + + + A compound datatype, with components: minimum, optimum, maximum, precedence, and conditionality. The minimum, optimum, and maximum components are s. The precedence component is either "force" or an . The conditionality component is either "discard" or "retain". If "minimum" is greater than optimum, it will be treated as if it had been set to "optimum". If "maximum" is less than optimum, it will be treated as if it had been set to "optimum". + + + + + + + + + + + + + A representation of an angle consisting of an optional '+' or '-' character immediately followed by a immediately followed by an angle unit identifier. Angle unit identifiers are: 'deg' (for degrees), 'grad' (for grads), and 'rad' (for radians). The specified values are normalized to the range 0deg to 360deg. A property may define additional constraints on the value. + + + + + + + + + + + + + A signed real percentage which consists of an optional '+' or '-' character followed by a sequence of digits followed by an optional '.' character and sequence of digits followed by '%'. A property may define additional constraints on the value. + + + + + + + + + + + + + + + + + + + + + + + + + + + + A string of characters representing a name. It must conform to the definition of an NCName in + + + + + + + + + + A string of characters identifying a font. + + + + + + + + + + + + + + + + + + + + + + + Either a string of characters representing a keyword or a color function defined in . The list of keyword color names is: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, and yellow. + + + + + + + + + + + + The function proportional-column-width(N[0]) + This returns a width as a fraction of the available width as ( N[0] / sum1 ) * available space + The parent table must have width="x" and table-layout="fixed" + + + + + + + + + + + , , proportional-column-width, or common-functions + + + + + + + + +