Importing a Schematron(blah.sch) from a directory into DocBo

<oXygen/> general issues.
dinodc
Posts: 19

Importing a Schematron(blah.sch) from a directory into DocBo

Thu May 08, 2014 9:45 pm

Hi,

I took overt this task to import several Schematrons into DocBook. I'm using oxygen XML Author. I guess previous who was task to do this said he tried to import but the schematron show unless they removed some tags, or something, for it to work. . .schematron would be displayed in our DocBook. can you help? Thanks!
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Thu May 08, 2014 10:18 pm

Sorry for the missing words.

Here is the request:

I took overt this task to import several Schematrons into DocBook. I'm using oxygen XML Author. I guess the previous person who was task to do this said he tried to import but the schematron wouldn't show in DocBook unless they removed some tags, or something, for it to work. . .schematron would be displayed in our DocBook. Can you help? Thanks!
adrian
Posts: 2443

Re: Importing a Schematron(blah.sch) from a directory into D

Fri May 09, 2014 12:21 pm

Hi,

It's not very clear to me what you're referring to when you say 'import several Schematrons into DocBook'. Schematrons are schema files and DocBook documents are XML content documents, so they don't really mix. You usually use Schematron to validate XML, so you would associate the schema with the document.

Do you want to associate the Schematron schema with the DocBook document in order to validate it?
You can do that within the DocBook document from menu > Document > Schema > Associate Schema and pick the Schematron schema.

Do you want to include the actual text content of the Schematron file in the DocBook document?
If that's it, you can use XInclude with @parse="text":
http://www.sagehill.net/docbookxsl/Modu ... ePlainText
e.g. Schematron schema listed in a 'programlisting' element in DocBook

Code: Select all

<programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" href="file:/path/to/my/file/schematron-schema.sch" parse="text"/></programlisting>

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Fri May 09, 2014 6:27 pm

Adrian ,

Yes, I need to import the actual text content of the Schematron file. We want to dynamically importing anything in a particular folder that contains all the schematron files and put in our DocBook which later will produce a PDF(we perform a MVN Install) which shows other information as well as the schematron content.

I will try to implement your solution.

Thanks!
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Fri May 09, 2014 9:21 pm

TO make simple and to see if I am on the right path I simplified my problem. I tired a 1 small text file on my local drive. Text works.. . I can see the content when I product a PDF. I changed parse="xml" and only the tags appear.

Code: Select all

<title>***Schematron File Name***</title>
  <para>
    <xi:include
      href="c:/SchTest/Test.xml" parse="xml"
   xmlns:xi="http://www.w3.org/2001/XInclude">
   
      <xi:fallback>
        <para><emphasis>FIXME:  MISSING XINCLUDE CONTENT</emphasis></para>
      </xi:fallback>               
    </xi:include>
  </para>


This is the PDF output:
<Plan>
<MissionInfoSet>
<MissionInfo>
<Property></Property>
<Property></Property>
<Property></Property>
<Property></Property>
<Property></Property>
</MissionInfo>
</MissionInfoSet>
</Plan>
adrian
Posts: 2443

Re: Importing a Schematron(blah.sch) from a directory into D

Fri May 09, 2014 10:53 pm

Hi,

You have two problems:
1. If you XInclude with @parse="xml", you won't obtain the content as text, but as the XML structure from the Schematron document, which is not valid in a DocBook document. You have to use @parse="text" to avoid the XML structure and instead obtain the text content.
2. If you put that XInclude in a para, the XIncluded content will get reformatted as any paragraph text and become unreadable. You want something similar to programlisting which preserves spaces and line breaks of the text content.

In addition to these, a less important but notable issue is that href has to be a URL, so for local files it should have the file protocol: file:/C:/....

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Fri May 09, 2014 11:02 pm

Here is the entire code:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="http://docbook.org/xml/5.0/rng/docbookxi.rng" schematypens="http://relaxng.org/ns/structure/1.0"?>
<?xml-model href="http://docbook.org/xml/5.0/rng/docbook.rng" type="application/xml" schematypens="http://purl.oclc.org/dsdl/schematron"?>

  <chapter version="5.0" xmlns="http://docbook.org/ns/docbook"
    xmlns:xi="http://www.w3.org/2001/XInclude">
      <title>LIST OF EXAMPLES</title>
        <para></para> 
          <sect1>
            <title>Schematron Source</title>
            <para></para>
            <sect2>
              <title>***Schematron File Name***</title>
                <para>
        <xi:include
          href="c:/SchTest/Test.xml" parse="xml">
            <xi:fallback>
                        <para><emphasis>FIXME:  MISSING XINCLUDE CONTENT</emphasis></para>
                      </xi:fallback>
                  </xi:include>
                    *******PLACE CODE HERE FOR NOW**********************
                </para>
            </sect2>
          </sect1>
  </chapter>


Test.xml content:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<Plan xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="GenericCommPlan.xsd"
Name="Sample"
Description="Sample CP"
CreationDate="130000ZNOV2013" Version="0.1">
   <MissionInfoSet>
      <MissionInfo Name="ABCV1">
         <Property Name="StartDate" Value="010000ZOCT2013"/>
         <Property Name="LocationName" Value="ZZZZZ"/>
         <Property Name="Long" Value="-17.000964"/>
         <Property Name="Lat" Value="08.000051"/>
         <Property Name="Radius" Value="1000"/>
      </MissionInfo>
   </MissionInfoSet>
</Plan>



And the result of the generated PDF we output:
<Plan>
<MissionInfoSet>
<MissionInfo>
<Property></Property>
<Property></Property>
<Property></Property>
<Property></Property>
<Property></Property>
</MissionInfo>
</MissionInfoSet>
</Plan>
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Fri May 09, 2014 11:19 pm

Adrian,

I removed the parse="xml" and changed to parse="text"..also commented out the <para> and replaced it with <programlisting>. I like that it finally shows the content of the xml.

Oh ok...don't use href for local...ok.

I did chnage the test.xml or a schematron file and it worked too.

Now that I see it in the schematron content in the PDF doc, I notice it gets busy and can over run. . .I guess I need to set the margins or something.

See, our first intent was to have a DocBook. After doing a build, it will import all the schematron files and its content and into DocBook's xml page. We perform a Maven Install and DocBook would output a PDF. We didn't want to manually insert each schematron. I wonder if we set it like a image. We used to use this format

Code: Select all

  <sidebar>
    <example>
    <title>MUOSContactLists Example</title>
    <screen>
    <![CDATA[
   <MissionInfoSet>
      <MissionInfo Name="ABCV1">
         <Property Name="StartDate" Value="010000ZOCT2013"/>
         <Property Name="LocationName" Value="ZZZZZ"/>
         <Property Name="Long" Value="-17.000964"/>
         <Property Name="Lat" Value="08.000051"/>
         <Property Name="Radius" Value="1000"/>
      </MissionInfo>
   </MissionInfoSet>
                 ]]>
    </screen>
    </example>
  </sidebar>
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Tue May 13, 2014 7:28 pm

I got it to import and show the content, on different test, of 1 XML and 1 schematron file from my local hard drive. Now, how would you import many files and its content to show in DocBook?

For 1 file I used: <xi:include href="file:///SchTest/Test.sch" parse="text">

What would be the syntax for multiple XML or schematron files in that directory?
adrian
Posts: 2443

Re: Importing a Schematron(blah.sch) from a directory into D

Tue May 13, 2014 8:50 pm

Hi,

An XInclude can only refer one file at a time, so you'll have to use multiple XInclude statements for multiple files.
Note that you can even nest them, so you could set up an XML (can be generated with an XSLT) that contains all the XIncludes and then XInclude this XML into the DocBook document.

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Tue May 13, 2014 10:52 pm

Thanks Adrian,

Glad to know the answer to that. I did add more includes and that worked. Is there a way to get the content to be more left justify? I used </programlisting> to keep the content the way I usually see it, but the content is going off to the right when I generate it in a PDF.
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Mon May 19, 2014 11:24 pm

To add to this same scenario above, where I was able to hard code the location of the schematron and using the xinclude and href. Now, how do I make it more dynamic, no hard coded, if someone else performs a build and their workspace is different name, how would I find the schematron? Would I some how use href and an xpointer? If so, can I have an example?
adrian
Posts: 2443

Re: Importing a Schematron(blah.sch) from a directory into D

Tue May 20, 2014 4:35 pm

Hi,

If you keep the same relative folder structure among various users, you can use relative references in the XInclude @hrefs. e.g.

Code: Select all

<xi:include href="relative/path/to/file.sch" parse="text">

By default a relative reference is resoled relative to the file where the XInclude is used.
If you want to use a different base (than the file) for the relative references, you can specify xml:base="file:/absolute/path/to/folder/" on the parent or root element where the XIncludes are used.

Or, if you already have absolute URIs everywhere, you could use an XML catalog that rewrites these and point them to a new location (usually relative to the XML catalog file itself).
http://www.oxygenxml.com/doc/ug-editor/ ... alogs.html
e.g.

Code: Select all

<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
    <rewriteURI uriStartString="file:/absolute/path/to/folder/" rewritePrefix="./"/>
    <rewriteSystem systemIdStartString="file:/absolute/path/to/folder/" rewritePrefix="./"/>
</catalog>

You can then add the XML catalog in Options > Preferences, XML > XML Catalog.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Fri Jul 18, 2014 8:03 pm

Thanks all for the importing into DocBook help!!!!!!! All works! Sorry for the delay for this comments.
dinodc
Posts: 19

Re: Importing a Schematron(blah.sch) from a directory into D

Fri Jul 18, 2014 8:06 pm

I have now a related issue. Someone at work likes what we did with importing but this time he needs to import and display a html page, not the raw data, not the code, but the html page to be imported into DocBook. Of course we will us the "include"...but parse=Text, parse="html", doesn't work for what we want. Can someone help? Thanks again!
george
Site Admin
Posts: 2100

Re: Importing a Schematron(blah.sch) from a directory into D

Sat Jul 19, 2014 7:49 am

When you include a file as text then that content is placed within a DocBook element as text. You cannot add HTML, XHTML or other XML content into a DocBook document. The schema will not allow that and also the XSLT stylesheets that process the document will not handle the new elements.

If your HTML content does not change in time then you can convert that to a DocBook section for example and include that section. The oXygen smart paste support may help you with this conversion.

The way to use HTML and DocBook together is to link from DocBook to the HTML file

Code: Select all

<link xlink:href="http://server/path/to/test.html">Link to an HTML file</link>

having the HTML file made available at http://server/path/to/test.html.

Best Regards,
George
George Cristian Bina
urbanrobots
Posts: 83
Location: San Francisco

Re: Importing a Schematron(blah.sch) from a directory into DocBo

Wed Jun 29, 2016 9:10 pm

hi~ We are using DITA, but this conversation may still apply.

Our schematron file is getting too large, and we'd like to parse it into several, focused schematron files.

This code:

Code: Select all

 <xi:include href="glossary_rules.sch" xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" />


does not seem to work...

In the files, this error occurs:
cvc-complex-type.2.4.a: Invalid content was found starting with element '{"http://purl.oclc.org/dsdl/schematron":schema}'. One of '{"http://purl.oclc.org/dsdl/schematron":diagnostics, "http://purl.oclc.org/dsdl/schematron":pattern, "http://purl.oclc.org/dsdl/schematron":include, "http://purl.oclc.org/dsdl/schematron":extends, "http://purl.oclc.org/dsdl/schematron":title, "http://purl.oclc.org/dsdl/schematron":ns, "http://purl.oclc.org/dsdl/schematron":p, "http://purl.oclc.org/dsdl/schematron":let, "http://purl.oclc.org/dsdl/schematron":phase, WC[""], WC[##other:"http://purl.oclc.org/dsdl/schematron",""]}' is expected.


Where is this include information supposed to exist?

Here is the "parent" schematron file header:

Code: Select all

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
    xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
    queryBinding="xslt2">
    <!-- Import the Glossary Schematron Rules -->
    <xi:include href="glossary_rules.sch" xmlns:xi="http://www.w3.org/2001/XInclude" parse="xml" />


Here is the "child" schematron file header:

Code: Select all

<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron"
            xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
            queryBinding="xslt2">


thanks, - nicholas
george
Site Admin
Posts: 2100

Re: Importing a Schematron(blah.sch) from a directory into DocBo

Thu Jun 30, 2016 10:28 am

The xi:include element will be replaced with the root element of the document you include, so you will end up with sch:schema within sch:schema, which is invalid in Schematron, thus the error message that you get.

You can use:

Code: Select all

<sch:extends href="glossary_rules.sch"/>


to obtain what you want - assuming the Schematron implementation supports extends/@href and the oXygen implementation supports that.

Best Regards,
George
George Cristian Bina

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 1 guest