Re: Where's the parallelize step?

Hi Norm,

>>>> QUESTION
>>>>
>>>> The identity step only allows me to connect its input port to the
>>>> output of one of the parallel workflows. I'm dumping the other
>>>> workflow's output. This seems rather bad. I can't think of what else
>>>> to do. Can you suggest a better way to handle the merging of two
>>>> parallel workflows?
>>
>>> <p:identity>
>>>   <p:input port="source">
>>>     <p:pipe step="branch-1" name="result"/>
>>>     <p:pipe step="branch-2" name="result"/>
>>>   </p:input>
>>> </p:identity>
>>
>> I tried that, and got this error:
>>
>>     Error  : Pipeline failed: err:XD0006: 
>>     2 documents appear on the 'source' port.
>>     If sequence is not specified, or has the 
>>     value false, then it is a dynamic error
>>     unless exactly one document appears on 
>>     the declared port.

>That's bizarre. The source port on p:identity *does* accept a
>sequence. Looks like a Calabash bug. Can you reproduce it in 0.9.8
>released this morning?


I just tried it. Same error. I put my files below, in case you'd like to try it for yourself.


>> Even if it did work, what would it mean? Doesn't p:identity mean
>> that the input flows unaltered to the output? Since there are two
>> inputs, which one flows through to the output?

>The output would be a sequence, the result from branch-1 preceding the
>result from branch-2. I'm not sure what you *expect* the result of the
>join to be...


Thanks. I guess that I really don't know what I expect. I am a newbie to workflow management, and am seeking guidance from the community on how to handle the merging of two parallel workflows.

/Roger

-------------------------------------
   parallel-workflow.xpl
-------------------------------------
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="validate-and-track">
        <p:input port="source">
            <p:document href="document.xml"/>
        </p:input>
        <p:output port="result">
            <p:pipe step="uuid" port="result"/>
        </p:output>
    

    <p:validate-with-xml-schema assert-valid="true" mode="strict" name="xsdValidation">
        <p:input port="schema">
            <p:document href="check-classifications.xsd"/>
        </p:input>
    </p:validate-with-xml-schema>

    
    <p:validate-with-schematron phase="classificationValidation" name="checkClassifications">
        <p:input port="source">
            <p:pipe step="validate-and-track" port="source" />
        </p:input>
        <p:input port="schema">
            <p:document href="check-classifications-and-reserved-words.sch"/>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:validate-with-schematron>
    
    
    <p:validate-with-schematron phase="reservedWordValidation" name="checkReservedWords">
        <p:input port="source">
            <p:pipe step="checkClassifications" port="result" />
        </p:input>
        <p:input port="schema">
            <p:document href="check-classifications-and-reserved-words.sch"/>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:validate-with-schematron>

    <p:identity name="merge">
        <p:input port="source">
            <p:pipe step="checkReservedWords" port="result" />
            <p:pipe step="xsdValidation" port="result" />
        </p:input>
    </p:identity>
    

    <p:insert position="first-child" match="/Document" name="insertTrackingElement">
        <p:input port="insertion">
            <p:inline>
                <TrackingNumber> </TrackingNumber>
            </p:inline>
        </p:input>
    </p:insert>

    
    <p:uuid match="/Document/TrackingNumber/text()" name="uuid">
        <p:input port="source">
            <p:pipe step="insertTrackingElement" port="result" />
        </p:input>
    </p:uuid>

</p:declare-step>


-------------------------------------
check-classifications.xsd
-------------------------------------
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">

    <xs:element name="Document">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="Para" maxOccurs="unbounded">
                    <xs:complexType>
                        <xs:simpleContent>
                            <xs:extension base="paraType">
                                <xs:attribute name="classification" type="classificationLevels" use="required"/>
                            </xs:extension>
                        </xs:simpleContent>
                    </xs:complexType>
                </xs:element>
            </xs:sequence>
            <xs:attribute name="classification" type="classificationLevels" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:simpleType name="classificationLevels">
        <xs:restriction base="xs:string">
            <xs:enumeration value="top-secret"/>
            <xs:enumeration value="secret"/>
            <xs:enumeration value="confidential"/>
            <xs:enumeration value="unclassified"/>
        </xs:restriction>
    </xs:simpleType>
    <xs:simpleType name="paraType">
        <xs:restriction base="xs:string">
            <xs:maxLength value="200"/>
            <xs:pattern value="[\sa-zA-Z0-9,;:\.]*"/>
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

-------------------------------------
check-classifications-and-reserved-words.sch
-------------------------------------
<?xml version="1.0"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron">

   <sch:phase id="classificationValidation">

      <sch:p>Validate that the document's security classification policy is valid.</sch:p>

       <sch:active pattern="SCP" />

   </sch:phase>

   <sch:phase id="reservedWordValidation">

      <sch:p>Validate that the document doesn't contain any reserved words.</sch:p>

       <sch:active pattern="RWF" />

   </sch:phase>

   <sch:pattern name="Security Classification Policy" id="SCP">

      <sch:p>A Para's classification value cannot be more sensitive 
         than the Document's classification value.</sch:p> 

      <sch:rule context="Para[@classification='top-secret']">

         <sch:assert test="/Document/@classification='top-secret'">
             If there is a Para is labeled "top-secret" then the Document  
             should be labeled top-secret
         </sch:assert>

      </sch:rule>

      <sch:rule context="Para[@classification='secret']">

         <sch:assert test="(/Document/@classification='top-secret') or
                           (/Document/@classification='secret')">
             If there is a Para is labeled "secret" then the Document  
             should be labeled either secret or top-secret
         </sch:assert>

      </sch:rule>

      <sch:rule context="Para[@classification='confidential']">

         <sch:assert test="(/Document/@classification='top-secret') or
                           (/Document/@classification='secret') or 
                           (/Document/@classification='confidential')">
             If there is a Para is labeled "confidential" then the Document  
             should be labeled either confidential, secret or top-secret
         </sch:assert>

      </sch:rule>

   </sch:pattern>

   <sch:pattern name="Reserved Word Filter" id="RWF">

      <sch:p>These reserved words are not allowed anywhere in the
         document: SCRIPT, FUNCTION.</sch:p> 

      <sch:rule context="Document">

         <sch:assert test="count(//node()[contains(.,'SCRIPT')]) = 0
                           and
                           count(//node()[contains(.,'FUNCTION')]) = 0">
             The document must not contain the words SCRIPT or FUNCTION
         </sch:assert>

      </sch:rule>

   </sch:pattern>

</sch:schema>


-------------------------------------
    document.xml
-------------------------------------
<?xml version="1.0"?>
<Document classification="secret">
    <Para classification="unclassified">
          One if by land, two if by sea;
    </Para>
    <Para classification="confidential">
          And I on the opposite shore will be, 
          Ready to ride and spread the alarm
    </Para>
    <Para classification="unclassified">
          Ready to ride and spread the alarm
          Through every Middlesex, village and farm,
    </Para>
    <Para classification="secret">
          For the country folk to be up and to arm.
    </Para>
</Document>

Received on Tuesday, 21 April 2009 12:56:36 UTC