Hi,
I am trying to convert a word xml into another xml file format using XSLT.
Here I need to check the all the following siblings with some condition. If that condition is satisfied, the control should exit from that loop.
How can i achieve this, I am desperately need this.
Details:
2.PERSONNEL YES NO N/A
a. Are there sufficient maintenance personnel to safely maintain company aircraft at primary facility and en route locations?
b. Does the new-hire process provide for:
(1) Sufficient background check?
(2) Drug and alcohol abuse testing?
c. Does the carrier experience a great deal of turnover?
d. Are the carrier’s maintenance employee’s union members?
(1) When is the contract up for renegotiations and are any
problems expected?
(2) What is the quality of the relationship between management
and the union?
This the Table in a Word Document (Screen Shot here: http://wikisend.com/download/298068/Untitled.png). When i save the word doc as word xml 2003 format, it will generate the following xml file.
This is the Input XML:( I tried to minimise it ASAP, but it is auto generated)
<w:tbl>
<w:tr wsp:rsidR="00E77079" wsp:rsidRPr="00E7149E" wsp:rsidTr="00B51904">
<w:tc>
<w:tcPr>
<w:tcW w:w="3852" w:type="pct"/>
<w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p wsp:rsidR="00E77079" wsp:rsidRPr="00221D14" wsp:rsidRDefault="00E77079" wsp:rsidP="00040FAA">
<w:pPr>
<w:tabs>
<w:tab w:val="left" w:pos="360"/>
<w:tab w:val="left" w:pos="720"/>
<w:tab w:val="left" w:pos="1080"/>
</w:tabs>
<w:rPr>
<w:b/>
<w:color w:val="000000"/>
</w:rPr>
</w:pPr>
<w:r wsp:rsidRPr="00221D14">
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
<w:br w:type="column"/>
</w:r>
<w:r>
<w:rPr>
<w:b/>
<w:b-cs/>
<w:color w:val="0000A0"/>
</w:rPr>
<w:t>2.</w:t>
</w:r>
<w:r wsp:rsidRPr="00221D14">
<w:rPr>
<w:b/>
<w:b-cs/>
<w:color w:val="0000A0"/>
</w:rPr>
<w:t>PERSONNEL</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="384" w:type="pct"/>
<w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p wsp:rsidR="00E77079" wsp:rsidRPr="00221D14" wsp:rsidRDefault="00E77079" wsp:rsidP="00040FAA">
<w:pPr>
<w:tabs>
<w:tab w:val="left" w:pos="360"/>
<w:tab w:val="left" w:pos="720"/>
<w:tab w:val="left" w:pos="1080"/>
</w:tabs>
<w:spacing w:before="100" w:before-autospacing="on" w:after="100" w:after-autospacing="on"/>
<w:jc w:val="center"/>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
</w:pPr>
<w:r wsp:rsidRPr="00221D14">
<w:rPr>
<w:b-cs/>
<w:color w:val="0000A0"/>
</w:rPr>
<w:t>YES</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="384" w:type="pct"/>
<w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p wsp:rsidR="00E77079" wsp:rsidRPr="00221D14" wsp:rsidRDefault="00E77079" wsp:rsidP="00040FAA">
<w:pPr>
<w:tabs>
<w:tab w:val="left" w:pos="360"/>
<w:tab w:val="left" w:pos="720"/>
<w:tab w:val="left" w:pos="1080"/>
</w:tabs>
<w:spacing w:before="100" w:before-autospacing="on" w:after="100" w:after-autospacing="on"/>
<w:jc w:val="center"/>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
</w:pPr>
<w:r wsp:rsidRPr="00221D14">
<w:rPr>
<w:b-cs/>
<w:color w:val="0000A0"/>
</w:rPr>
<w:t>NO</w:t>
</w:r>
</w:p>
</w:tc>
<w:tc>
<w:tcPr>
<w:tcW w:w="381" w:type="pct"/>
<w:shd w:val="clear" w:color="auto" w:fill="auto"/>
</w:tcPr>
<w:p wsp:rsidR="00E77079" wsp:rsidRPr="00221D14" wsp:rsidRDefault="00E77079" wsp:rsidP="00040FAA">
<w:pPr>
<w:tabs>
<w:tab w:val="left" w:pos="360"/>
<w:tab w:val="left" w:pos="720"/>
<w:tab w:val="left" w:pos="1080"/>
</w:tabs>
<w:spacing w:before="100" w:before-autospacing="on" w:after="100" w:after-autospacing="on"/>
<w:jc w:val="center"/>
<w:rPr>
<w:color w:val="000000"/>
</w:rPr>
</w:pPr>
<w:r wsp:rsidRPr="00221D14">
<w:rPr>
<w:b-cs/>
<w:color w:val="0000A0"/>
</w:rPr>
<w:t>N/A</w:t>
</w:r>
</w:p>
</w:tc>
</w:tr>
<w:tr><w:tr>
.....Similar Rows...
</w:tbl>
XSLT:
<xsl:for-each select="ns1:tr">
<xsl:element name="Question">
<xsl:variable name="Questionrow">
<xsl:for-each select="ns1:tc/ns1:p/ns1:r">
<xsl:value-of select="ns1:t"/>
</xsl:for-each>
</xsl:variable>
<xsl:attribute name="label">
<xsl:value-of select="substring(normalize-space($Questionrow),1,1)"/>
</xsl:attribute>
<xsl:attribute name="displayorder">
<xsl:value-of select="position() - 2"/>
</xsl:attribute>
<xsl:attribute name="questiontype">
<xsl:text>DoDQuestion</xsl:text>
</xsl:attribute>
<xsl:element name="Text">
<xsl:variable name="length" select="string-length(substring-before(normalize-space($Questionrow),'?'))"/>
<xsl:value-of select="substring(normalize-space($Questionrow),3,($length))"/>
</xsl:element>
<xsl:element name="Subquestions">
<xsl:for-each select="following-sibling::*">
<![CDATA[Trying to do the same as above. But How to Exit this loop when next Question Comes.]]>
</xsl:for-each>
</xsl:element>
</xsl:element>
</xsl:for-each>
Required XML Format:
<Section label="2" title="OPERATIONS MANAGEMENT (Senior Ops Manager)" displayorder="1">
<Questions>
<Question label="a" displayorder="1" questiontype="DoDQuestion">
<Text>How would you assess your relationship with the FAA?</Text>
<AnswerChoices>
<AnswerChoice code="" label="" displayorder="0" type="text" />
</AnswerChoices>
</Question>
<Question label="b" displayorder="0" questiontype="DoDQuestion">
<Text>How does operations management emphasize safety as a top priority?</Text>
<AnswerChoices>
<AnswerChoice code="" label="" displayorder="0" type="text" />
</AnswerChoices>
<Subquestions>
<Subquestion label="1" level="1" displayorder="0" questiontype="DoDQuestion">
<Text>Is your safety philosophy published and accessible to line crewmembers?</Text>
<AnswerChoices>
<AnswerChoice code="Yes" label="Yes" displayorder="0" type="radio" />
<AnswerChoice code="No" label="No" displayorder="1" type="radio" />
<AnswerChoice code="NA" label="N/A" displayorder="2" type="radio" />
</AnswerChoices>
</Subquestion>
<Subquestion label="2" level="1" displayorder="1" questiontype="DoDQuestion">
<Text>Do you interact regularly with the company’s safety focal point?</Text>
<AnswerChoices>
<AnswerChoice code="Yes" label="Yes" displayorder="0" type="radio" />
<AnswerChoice code="No" label="No" displayorder="1" type="radio" />
<AnswerChoice code="NA" label="N/A" displayorder="2" type="radio" />
</AnswerChoices>
</Subquestion>
</Subquestions>
</Question>
<Question label="c" displayorder="2" questiontype="DoDQuestion">
<Text>Does your company operate into FAA or DOD designated special airfields?</Text>
<AnswerChoices>
<AnswerChoice code="Yes" label="Yes" displayorder="0" type="radio" />
<AnswerChoice code="No" label="No" displayorder="1" type="radio" />
<AnswerChoice code="NA" label="N/A" displayorder="2" type="radio" />
</AnswerChoices>
</Question>
<Question label="d" displayorder="3" questiontype="DoDQuestion">
<Text>Does your company operate any missions it considers higher risk than standard?</Text>
<AnswerChoices>
<AnswerChoice code="Yes" label="Yes" displayorder="0" type="radio" />
<AnswerChoice code="No" label="No" displayorder="1" type="radio" />
<AnswerChoice code="NA" label="N/A" displayorder="2" type="radio" />
</AnswerChoices>
<Subquestions>
<Subquestion label="•" level="1" displayorder="0" questiontype="DoDQuestion">
<Text>Have these been identified in operations manuals?</Text>
<AnswerChoices>
<AnswerChoice code="Yes" label="Yes" displayorder="0" type="radio" />
<AnswerChoice code="No" label="No" displayorder="1" type="radio" />
<AnswerChoice code="NA" label="N/A" displayorder="2" type="radio" />
</AnswerChoices>
</Subquestion>
<Subquestion label="•" level="1" displayorder="1" questiontype="DoDQuestion">
<Text>Is there oversight of scheduling for theses increased risk flights?</Text>
<AnswerChoices>
<AnswerChoice code="Yes" label="Yes" displayorder="0" type="radio" />
<AnswerChoice code="No" label="No" displayorder="1" type="radio" />
<AnswerChoice code="NA" label="N/A" displayorder="2" type="radio" />
</AnswerChoices>
</Subquestion>
</Subquestions>
</Question>
</Questions>
</Section>