adding windows and cross-platform path support

This commit is contained in:
brent s. 2022-03-04 06:36:51 -05:00
parent 9b05156215
commit ea935b642f
Signed by: bts
GPG Key ID: 8C004C2F93481F6B
2 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="./linux.xsd"/>
<xs:include schemaLocation="./windows.xsd"/>

<!-- ABSOLUTE directory path -->
<xs:simpleType name="t_xplat_dirpath">
<xs:union memberTypes="t_linux_dirpath t_windows_dirpath"/>
</xs:simpleType>

<!-- RELATIVE directory path -->
<xs:simpleType name="t_xplat_reldirpath">
<xs:union memberTypes="t_linux_reldirpath t_windows_reldirpath"/>
</xs:simpleType>

<!-- ABSOLUTE file path -->
<xs:simpleType name="t_xplat_filepath">
<xs:union memberTypes="t_linux_filepath t_windows_filepath"/>
</xs:simpleType>

<!-- RELATIVE file path -->
<xs:simpleType name="t_xplat_relfilepath">
<xs:union memberTypes="t_linux_relfilepath t_windows_relfilepath"/>
</xs:simpleType>

<!-- ABSOLUTE path (file or directory) -->
<xs:simpleType name="t_xplat_path">
<xs:union memberTypes="t_linux_path t_windows_path"/>
</xs:simpleType>

<!-- RELATIVE path (file or directory) -->
<xs:simpleType name="t_xplat_relpath">
<xs:union memberTypes="t_linux_relpath t_windows_relpath"/>
</xs:simpleType>

<!-- ANY valid value for the above types. -->
<xs:simpleType name="t_xplat_anypath">
<xs:union memberTypes="t_linux_anypath t_windows_anypath"/>
</xs:simpleType>

<!-- RELATIVE or ABSOLUTE file path -->
<xs:simpleType name="t_xplat_anyfile">
<xs:union memberTypes="t_linux_anyfile t_windows_anyfile"/>
</xs:simpleType>

<!-- RELATIVE or ABSOLUTE dir path -->
<xs:simpleType name="t_xplat_anydir">
<xs:union memberTypes="t_linux_anydir t_windows_anydir"/>
</xs:simpleType>

</xs:schema

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified"
attributeFormDefault="unqualified">

<xs:include schemaLocation="./std.xsd"/>

<!-- ABSOLUTE directory path -->
<!-- Getting this regex right for Windows is a nightmare. This is just intended to check in a very basic manner. -->
<xs:simpleType name="t_windows_dirpath">
<xs:restriction base="xs:string">
<xs:pattern value="\s*(~|[A-Za-z]+:)(\\[^\\]*)+\\?\s*"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>

<!-- RELATIVE directory path -->
<!-- Don't trust this. XML patterns don't support lookahead/lookbehind, so we can't negate a char sequence. -->
<xs:simpleType name="t_windows_reldirpath">
<xs:restriction base="xs:string">
<xs:pattern value="\s*[^\\](([^\\]*)+\\?)+\s*"/>
</xs:restriction>
</xs:simpleType>

<!-- ABSOLUTE file path -->
<xs:simpleType name="t_windows_filepath">
<xs:restriction base="xs:string">
<xs:pattern value="\s*(~|[A-Za-z]+:)?(\\[^\\]+)+\s*"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>

<!-- RELATIVE file path -->
<xs:simpleType name="t_windows_relfilepath">
<xs:restriction base="xs:string">
<xs:pattern value="\s*([^\\]+)(\\[^\\]+)*([^\\])*\s*"/>
<xs:whiteSpace value="collapse"/>
</xs:restriction>
</xs:simpleType>

<!-- ABSOLUTE path (file or directory) -->
<xs:simpleType name="t_windows_path">
<xs:union memberTypes="t_windows_dirpath t_windows_filepath"/>
</xs:simpleType>

<!-- RELATIVE path (file or directory) -->
<xs:simpleType name="t_windows_relpath">
<xs:union memberTypes="t_windows_reldirpath t_windows_relfilepath"/>
</xs:simpleType>

<!-- ANY valid value for the above types. -->
<xs:simpleType name="t_windows_anypath">
<xs:union memberTypes="t_windows_path t_windows_relpath"/>
</xs:simpleType>

<!-- RELATIVE or ABSOLUTE file path -->
<xs:simpleType name="t_windows_anyfile">
<xs:union memberTypes="t_windows_filepath t_windows_relfilepath"/>
</xs:simpleType>

<!-- RELATIVE or ABSOLUTE dir path -->
<xs:simpleType name="t_windows_anydir">
<xs:union memberTypes="t_windows_dirpath t_windows_reldirpath"/>
</xs:simpleType>

</xs:schema>