Re: FW: Question regarding the attribute editor
Hussein Shafie <[email protected]> Thu, 10 Nov 2022 12:28:58 +0100
| Newsgroups | gmane.editors.xxe.general |
|---|---|
| Message-ID | <[email protected]> |
On 11/9/22 13:03, Hurd, Alex wrote:
>
> I have added the attributes “Entity_x” and “Entity_y” (for use in
> testing purposes) to the Attributes list for the stylesheet in
> C:\Program Files (x86)\XMLmind_DocBook_Editor\addon\profiling\docbook. I
> see these attributes now appear in the profiles file and are selectable.
> I have sent with this message all files I am using to test the new
> attributes have made. Although it still doenst seem to work the way I
> want it to but I am not sure if it’s because of wrong use of the
> conditional formatting tool or the custom attributes still aren’t
> implemented correctly.
>
> Note:
>
> * I use the easy profiling addon, I have sent with this email the
> .profiles file.
> * I have selected the DocBook profiling XSL
>
> What I want to do is use these new attributes is to designate an element
> as part of an entity by activating the corresponding attribute, the
> attribute in this case only needs the “Yes” because there are only two
> cases, attribute is disabled or attribute is enabled. This might seem
> counterintuitive but if this works we will add a lot more attributes and
> profiles. What I want to do is best explained through an example:
>
> Imagine that there are multiple elements, half of the elements have
> attribute “Entity_x” and the other half have attribute “Entity_y”.
> imagine I have the profile selected with only “Entity_x” and no
> “Entity_y”, then I want to automatically filter out all instances that
> don’t have “Entity_x”, event elements with no attribute at all. is this
> possible given my current setup? Is there a way to automatically filter
> all elements that don’t mention the corresponding attribute in the profile?
>
Let's start with the simplest possible conditional processing for DocBook.
A conditional processing attribute such as your Entity_x must have
*several* *mutually* *exclusive* *values*. Here, I chose Yes and No.
(Let's forget about conditional processing attribute Entity_y for this
simple case.)
Excerpts from attached modified docbook51/rng/V5.1/docbook.rng
---
<define name="db.common.base.attributes">
<interleave>
<optional>
<ref name="db.version.attribute"/>
</optional>
<optional>
<ref name="db.xml.lang.attribute"/>
</optional>
<optional>
<ref name="db.xml.base.attribute"/>
</optional>
<optional>
<ref name="db.remap.attribute"/>
</optional>
<optional>
<ref name="db.xreflabel.attribute"/>
</optional>
<optional>
<ref name="db.revisionflag.attribute"/>
</optional>
<optional>
<ref name="db.dir.attribute"/>
</optional>
<ref name="db.effectivity.attributes"/>
<ref name="db.rdfalite.attributes"/>
<ref name="db.transclusion.attributes"/>
<optional>
<ref name="entity.x.attribute"/>
</optional>
</interleave>
</define>
<define name="entity.x.attribute">
<attribute name="Entity_x">
<choice>
<value>Yes</value>
<value>No</value>
</choice>
</attribute>
</define>
---
Profile "Case1" is when Entity_x=Yes
Profile "Case2" is when Entity_x=No
Attached "Test.profiles" (NOT your 'TESTING PROFILES.profiles')
---
<profiles class="com.xmlmind.xmleditext.profiling.docbook.DBProfileSet"
unselectedProfileStyle="background-image: icon(hatch1, #FFCCCC);"
xmlns="http://www.xmlmind.com/xmleditor/schema/profiling"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:prf="http://www.xmlmind.com/xmleditor/schema/profiling"
xmlns:ns="http://www.w3.org/1999/xhtml">
<attributes>
<attribute allowMultipleValues="false" name="Entity_x">
<value>Yes</value>
<value>No</value>
</attribute>
</attributes>
<profile implementation="Test_files/Case1.xslt" xml:id="Case1">
<attribute name="Entity_x">
<value>Yes</value>
</attribute>
</profile>
<profile implementation="Test_files/Case2.xslt" xml:id="Case2">
<attribute name="Entity_x">
<value>No</value>
</attribute>
</profile>
</profiles>
___
Note that the unselected profile is given a pink hatched background
pattern, which means "this will be excluded from the deliverables". See
attached screenshot.
What I've to use condition processing attribute Entity_x:
1)
a) Copied attached modified "docbook.rng" to docbook51/rng/V5.1/
b) Copied your modified "attributes.list" to profiling/docbook/ to teach
our easy profiling addon about attributes Entity_x and Entity_y (not
used here).
2) IMPORTANT: Opened attached Test.profiles and forced a "File|Save As"
to disk. This creates underlying conditional processing utility files
"Test_files/Case1.xslt" and "Case2.xslt".
2) Opened attached "Test.xml" (NOT your test file):
---
<section version="5.1" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:trans="http://docbook.org/ns/transclusion"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<title>Testing document</title>
<para>Twp paragraphs:</para>
<para Entity_x="Yes">AATESTING1 (<literal>Entity_x=Yes</literal>).</para>
<para Entity_x="No">AATESTING2 (<literal>Entity_x=No</literal>).</para>
</section>
---
3) IMPORTANT: Used "Preferences|Customize Configuration|Customize
Document Conversion Stylesheets" to select the DocBook profiling XSL
stylesheets. See attached screenshot "style_unselected_profile.png".
4) Used "DocBook|Condition Processing" to select "Test.profiles" and
profile "Case1". See attached screenshot "select_profile_case1.png".
5) The paragraph having Entity_x=No is immediately given a pink hatched
background to indicate that this paragraph will be filtered out from the
generated PDF file. See attached screenshot "profile_case1_selected.png".
6) Used "Docbook|Convert Document|Convert to PDF" to generate attached
"Case1.pdf". Note that the paragraph having Entity_x=No is not found in
this PDF.
As expected, if now I select profile "Case2", I get this other
screenshot "profile_case2_selected.png" and "Case2.pdf".
docbook.rng
(application/xml, 543.7 KB) - not displayed
Test.profiles
(text/xml, 973 B)
<?xml version="1.0" encoding="UTF-8"?>
<profiles class="com.xmlmind.xmleditext.profiling.docbook.DBProfileSet"
unselectedProfileStyle="background-image: icon(hatch1, #FFCCCC);"
xmlns="http://www.xmlmind.com/xmleditor/schema/profiling"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:prf="http://www.xmlmind.com/xmleditor/schema/profiling"
xmlns:ns="http://www.w3.org/1999/xhtml">
<attributes>
<attribute allowMultipleValues="false" name="Entity_x">
<value>Yes</value>
<value>No</value>
</attribute>
</attributes>
<profile implementation="Test_files/Case1.xslt" xml:id="Case1">
<attribute name="Entity_x">
<value>Yes</value>
</attribute>
</profile>
<profile implementation="Test_files/Case2.xslt" xml:id="Case2">
<attribute name="Entity_x">
<value>No</value>
</attribute>
</profile>
</profiles>
Test.xml
(text/xml, 766 B)
<?xml version="1.0" encoding="UTF-8"?>
<section version="5.1" xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:trans="http://docbook.org/ns/transclusion"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:m="http://www.w3.org/1998/Math/MathML"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:db="http://docbook.org/ns/docbook">
<title>Testing document</title>
<para>Twp paragraphs:</para>
<para Entity_x="Yes">AATESTING1 (<literal>Entity_x=Yes</literal>).</para>
<para Entity_x="No">AATESTING2 (<literal>Entity_x=No</literal>).</para>
</section>
style_unselected_profile.png
(image/png, 125 KB) - not displayed
select_profile_case1.png
(image/png, 63.8 KB) - not displayed
profile_case1_selected.png
(image/png, 4.9 KB) - not displayed