Skip to content

Commit

Permalink
Merge pull request #237 from ndw/allow-foreign
Browse files Browse the repository at this point in the history
Allow foreign namespace-qualified attributes on DocBook elements
  • Loading branch information
ndw committed Aug 13, 2022
2 parents 11395ac + fe1c076 commit 3281aba
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 11 deletions.
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ fileTree(dir: "${projectDir}/src/test").each { testfile ->
input document
output "${buildDir}/test/rng/${fn}"
schema "${buildDir}/schemas/rng/${packageMap[schema_name]}/${schema_name}.rng"
errorHandler new CollectingErrorHandler()
errorHandler new CollectingErrorHandler(System.err)
idref (schema_name != 'website' && schema_name != 'website-full' && schema_name != 'dbforms')
assertValid false
assertValid true
}
pass_tests.dependsOn t
baseTests[schema_name].dependsOn t
Expand All @@ -394,9 +394,9 @@ fileTree(dir: "${projectDir}/src/test").each { testfile ->
input document
output "${buildDir}/test/sch/${fn}"
schema "${buildDir}/schemas/sch/${packageMap[schema_name]}/${schema_name}.sch"
errorHandler new CollectingErrorHandler()
errorHandler new CollectingErrorHandler(System.err)
idref (schema_name != 'website' && schema_name != 'website-full' && schema_name != 'dbforms')
assertValid false
assertValid true
}
pass_tests.dependsOn t
baseTests[schema_name].dependsOn t
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ org.gradle.workers.max=3
systemProp.javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl

saxonVersion = 11.3
resolverVersion = 4.4.3
dbver = 5.2CR2
resolverVersion = 4.5.0
dbver = 5.2CR3
xslTNGversion = 1.7.1

oasisDocBookVersion=5.2
Expand Down
11 changes: 11 additions & 0 deletions src/dbits/relaxng/dbits/dbits.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@
namespace db = "http://docbook.org/ns/docbook"
namespace its = "http://www.w3.org/2005/11/its"
namespace html = "http://www.w3.org/1999/xhtml"
namespace xml = "http://www.w3.org/XML/1998/namespace"
namespace xlink = "http://www.w3.org/1999/xlink"
namespace trans = "http://docbook.org/ns/transclusion"
namespace local = ""

include "../../../docbook/relaxng/docbook/docbook.rnc" {
# Exclude ITS markup from "wildcard" element
Expand All @@ -81,6 +85,13 @@ include "../../../docbook/relaxng/docbook/docbook.rnc" {
| text
| db._any)*
}

# Exclude ITS markup from "any other" attribute
db._any_other.attribute =
[
db:refpurpose [ "Any attribute in an other explicit namespace." ]
]
attribute * - (db:* | xml:* | xlink:* | trans:* | its:* | local:*) { text }
}

# Include base ITS schema
Expand Down
11 changes: 11 additions & 0 deletions src/dbits/relaxng/dbitsxi/dbitsxi.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ namespace db = "http://docbook.org/ns/docbook"
namespace src = "http://nwalsh.com/xmlns/litprog/fragment"
namespace html = "http://www.w3.org/1999/xhtml"
namespace its = "http://www.w3.org/2005/11/its"
namespace xml = "http://www.w3.org/XML/1998/namespace"
namespace xlink = "http://www.w3.org/1999/xlink"
namespace trans = "http://docbook.org/ns/transclusion"
namespace local = ""
default namespace = "http://docbook.org/ns/docbook"

include "../../../docbook/relaxng/docbookxi/docbookxi.rnc" {
Expand All @@ -14,6 +18,13 @@ include "../../../docbook/relaxng/docbookxi/docbookxi.rnc" {
| text
| db._any)*
}

# Exclude ITS markup from "any other" attribute
db._any_other.attribute =
[
db:refpurpose [ "Any attribute in an other explicit namespace." ]
]
attribute * - (db:* | xml:* | xlink:* | trans:* | its:* | local:*) { text }
}

# Include base ITS schema
Expand Down
2 changes: 1 addition & 1 deletion src/docbook/java/org/docbook/schemas/docbook/DocBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// some tests to make sure the testing version is correct.

public final class DocBook {
public static final String[] VERSIONS = {"4.5", "5.0", "5.1", "5.2", "5.2CR2"};
public static final String[] VERSIONS = {"4.5", "5.0", "5.1", "5.2", "5.2CR3"};

public static final String DOCBOOK_CATALOG_PATH = "/org/docbook/schemas/docbook/catalog.xml";

Expand Down
9 changes: 9 additions & 0 deletions src/docbook/relaxng/docbook/pool.rnc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ namespace rng = "http://relaxng.org/ns/structure/1.0"
namespace s = "http://purl.oclc.org/dsdl/schematron"
namespace db = "http://docbook.org/ns/docbook"
namespace dbx = "http://sourceforge.net/projects/docbook/defguide/schema/extra-markup"
namespace xml = "http://www.w3.org/XML/1998/namespace"
namespace xlink = "http://www.w3.org/1999/xlink"
namespace trans = "http://docbook.org/ns/transclusion"
namespace html = "http://www.w3.org/1999/xhtml"
namespace a = "http://relaxng.org/ns/compatibility/annotations/1.0"
namespace local = ""
default namespace = "http://docbook.org/ns/docbook"

# ======================================================================
Expand Down Expand Up @@ -53,6 +55,12 @@ div {
]
attribute * { text }

db._any_other.attribute =
[
db:refpurpose [ "Any attribute in an other explicit namespace." ]
]
attribute * - (db:* | xml:* | xlink:* | trans:* | local:*) { text }

db._any =
element * - db:* { (db._any.attribute | text | db._any)* }
}
Expand Down Expand Up @@ -452,6 +460,7 @@ db.common.base.attributes =
& db.effectivity.attributes
& db.rdfalite.attributes
& db.common.transclusion.attributes
& db._any_other.attribute*

db.common.attributes =
db.xml.id.attribute?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// some tests to make sure the testing version is correct.

public final class Publishers {
public static final String[] VERSIONS = {"1.0", "5.2", "5.2CR2"};
public static final String[] VERSIONS = {"1.0", "5.2", "5.2CR3"};

public static final String PUBLISHERS_CATALOG_PATH = "/org/docbook/schemas/publishers/catalog.xml";

Expand Down
2 changes: 1 addition & 1 deletion src/test/relaxng/dbforms/pass/form-001.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<article xmlns="http://docbook.org/ns/docbook"
version="htmlforms-5.2">
<title>A forms example</title>
<form xmlns="http://www.w3.org/1999/xhtml">
<form xmlns="http://www.w3.org/1999/xhtml" action="http://example.com/">
<input name="text"/>
</form>
</article>
9 changes: 9 additions & 0 deletions src/test/relaxng/docbook/fail/foreign-ns.001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<article xmlns="http://docbook.org/ns/docbook"
version="5.2">
<title>Article wrapper</title>

<para unqualified-name="this is not allowed">You can put foreign namespaced
elements on any DocBook element. They must be in an explicit
namespace other than the DocBook namespace.</para>

</article>
10 changes: 10 additions & 0 deletions src/test/relaxng/docbook/fail/foreign-ns.002.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<article xmlns="http://docbook.org/ns/docbook"
xmlns:db="http://docbook.org/ns/docbook"
version="5.2">
<title>Article wrapper</title>

<para db:name="this is also not ok">You can put foreign namespaced
elements on any DocBook element. They must be in an explicit
namespace other than the DocBook namespace.</para>

</article>
10 changes: 10 additions & 0 deletions src/test/relaxng/docbook/pass/foreign-ns.001.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<article xmlns="http://docbook.org/ns/docbook"
xmlns:ex="http://example.com/"
version="5.2">
<title>Article wrapper</title>

<para ex:name="this is ok">You can put foreign namespaced
elements on any DocBook element. They must be in an explicit
namespace other than the DocBook namespace.</para>

</article>
3 changes: 1 addition & 2 deletions src/test/relaxng/docbook/pass/xref.002.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<article xmlns="http://docbook.org/ns/docbook" version="5.0">
<info>
<title>Article wrapper</title>
<x:irrelevant xmlns:x="http://example.com/doesntmatter"
xml:id="xreftext">Xref Endterm</x:irrelevant>
<bibliomisc role="xreftext" xml:id="xreftext">Xref Endterm</bibliomisc>
</info>

<para>This is an xref test.</para>
Expand Down

0 comments on commit 3281aba

Please sign in to comment.