Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple xhtml documents with document() function

Status
Not open for further replies.

nicolrob

Programmer
Jul 5, 2005
2
US
I have multiple xhtml files that I want to access with the document() function. Each xhtml file has multiple <p> elements with a numeric id attribute <p id="1">. I want to match this id number with a <paragraph> element of the xml file that the xslt is applied on, using the key()function. My xlst opens all the xhtml files but only matches the <p> with the <paragraph> for the fist xhtml the remaining xhtml files are not match. How can I match elements when the document() function opens multiple xhtml files?
 
Post your XSL, its not entirely clear what you mean.

Jon

"Asteroids do not concern me, Admiral. I want that ship, not excuses.
 
Thank you for the replay.
This is the xml file that the xsl is applyed on.
<?xml version="1.0" encoding="UTF-8"?><!--generated with grouping 2 wich is run after grouping 1 -->

<dataroot>
<HFC_x0020_summarization_x0020_data>
<Document_x0020_number xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">Resource 31</Document_x0020_number>
<title xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">Smith, S. L., &amp; Moiser, J. N. (1986). Guidelines for designing user interface software. Bedford, MA: US Air Force, Electronic Systems Division. (Document No. TR-86-278)</title>
<beginning_x0020_par_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00085</beginning_x0020_par_x0020_ID>
<ending_x0020_par_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00090</ending_x0020_par_x0020_ID>
<excerpt_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00085-00090</excerpt_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00085</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00086</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00087</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00088</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00089</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00090</paragraph_x0020_ID>
<sequence>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">360</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">400</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">410</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">470</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]</comments>
</sequence>
</HFC_x0020_summarization_x0020_data>
<HFC_x0020_summarization_x0020_data>
<Document_x0020_number xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">Resource 31</Document_x0020_number>
<title xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">Smith, S. L., &amp; Moiser, J. N. (1986). Guidelines for designing user interface software. Bedford, MA: US Air Force, Electronic Systems Division. (Document No. TR-86-278)</title>
<beginning_x0020_par_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00273</beginning_x0020_par_x0020_ID>
<ending_x0020_par_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00276</ending_x0020_par_x0020_ID>
<excerpt_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00273-00276</excerpt_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00273</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00274</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00275</paragraph_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0031_00_00276</paragraph_x0020_ID>
<sequence>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">400</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]1</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">400</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]2</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">410</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]2</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">410</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]1</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">470</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]2</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">470</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 21 Apr 03]1</comments>
</sequence>
</HFC_x0020_summarization_x0020_data>
<HFC_x0020_summarization_x0020_data>
<Document_x0020_number xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">Resource 33</Document_x0020_number>
<title xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">Design Criteria Standard, Mil-Std-1472E 31 October 1996, Superceding Mil-Std-1472D 10 February 1994</title>
<beginning_x0020_par_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0033_02_00125</beginning_x0020_par_x0020_ID>
<ending_x0020_par_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0033_02_00125</ending_x0020_par_x0020_ID>
<excerpt_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0033_02_00125-00125</excerpt_x0020_ID>
<paragraph_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">RES_0033_02_00125</paragraph_x0020_ID>
<sequence>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">400</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 22 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">400</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 22 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">400</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 22 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">410</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 22 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">410</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 22 Apr 03]</comments>
<HFC_x0020_ID xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">410</HFC_x0020_ID>
<comments xmlns:eek:d="urn:schemas-microsoft-com:eek:fficedata">[KF 22 Apr 03]</comments>
</sequence>
</HFC_x0020_summarization_x0020_data>
</dataroot>

Next is the xsl.
<?xml version="1.0" encoding="UTF-8"?>
<!-- Prints all the documents at once-->
<xsl:stylesheet version="2.0" xmlns:xsl=" xmlns:fo=" xmlns:xs=" xmlns:fn=" xmlns:xdt=" xmlns:xh=" <!-- Merges xml report generated by access and process by group 1.2.xsl with source xhtml documents -->
<xsl:eek:utput method="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
<xsl:variable name="root" select="'R:\Job Aid\Job Aid Development\Develop Image Report\Documets\'"/>
<xsl:template name="find_path">
<xsl:param name="pID" as="xs:string"/>
<xsl:variable name="document_type">
<xsl:choose>
<xsl:when test="substring-before($pID, '_') = 'RES'">Resources\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'AC'">ACs\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'FAR'">FARs\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '-') = 'ANM'">Policies\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'ARINC'">Standards\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'RTCA'">Standards\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'SAE'">Standards\XHTML\</xsl:when>
<xsl:when test="substring-before($pID, '-') = 'TSO'">TSOs\XHTML\</xsl:when>
</xsl:choose>
</xsl:variable>
<xsl:variable name="doc_name">
<xsl:choose>
<xsl:when test="substring-before($pID, '_') = 'RES'">
<xsl:value-of select="concat(substring($pID, 1, 8), '\', substring($pID, 1, 11))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'AC'">
<xsl:value-of select="if (string-length($pID)=20) then (concat(substring($pID, 1, 10), '\', substring($pID, 1, 13))) else (concat(substring($pID, 1, 11), '\', substring($pID, 1, 14)))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'FAR'">
<xsl:value-of select="concat(substring($pID, 1, 7), '\', substring($pID, 1, 12))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '-') = 'ANM'">
<xsl:value-of select="if (string-length($pID) = 18) then (concat(substring($pID, 1, 9), '\', substring($pID, 1, 12))) else (concat(substring($pID, 1, 10), '\', substring($pID, 1, 13)))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'ARINC'">
<xsl:value-of select="concat(substring($pID, 1, string-length($pID)-9), '\', substring($pID, 1, string-length($pID)-6))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'RTCA'">
<xsl:value-of select="if (string-length($pID) = 20) then (concat(substring($pID, 1, 11), '\', substring($pID, 1, 14))) else (concat(substring($pID, 1, 12), '\', substring($pID, 1, 15)))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '_') = 'SAE'">
<xsl:value-of select="concat(substring($pID, 1, string-length($pID)-9), '\', substring($pID, 1, string-length($pID)-6))"/>
</xsl:when>
<xsl:when test="substring-before($pID, '-') = 'TSO'">
<xsl:value-of select="if (string-length($pID) = 19) then (concat(substring($pID, 1, string-length($pID)-10), '\', substring($pID, 1, string-length($pID)-7))) else (concat(substring($pID, 1, string-length($pID)-9), '\', substring($pID, 1, string-length($pID)-6)))"/>
</xsl:when>
</xsl:choose>
</xsl:variable>
<!-- Prints the the value of each path for each paragraph ID-->
<xsl:value-of select="concat($root, $document_type, $doc_name, '.xhtml')"/>
</xsl:template>
<xsl:key name="text_in_xhtml" match="//xh:p" use="@id"/>
<xsl:template match="/">
<xsl:for-each select="//paragraph_x0020_ID">
<xsl:variable name="filename">
<xsl:call-template name="find_path">
<xsl:with-param name="pID" select="."/>
</xsl:call-template>
</xsl:variable>
<!--
<xsl:value-of select="$filename"/>
-->
<xsl:variable name="beginningID" select="."/>
<xsl:variable name="files" select="document($filename)"/>
<xsl:for-each select="$files">
<xsl:copy-of select="key('text_in_xhtml', $beginningID)"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

And the XHTML files that I want to open look like this.
<head>
<meta content="HTML Tidy for Windows (vers 1st November 2002), see name="generator"></meta>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"></meta>
<meta name="Generator" content="Microsoft Word 11 (filtered)"></meta>
<title>1 DATA ENTRY</title>
<style type="text/css">
/**/
&lt;!--
/* Font Definitions */
@font-face
{font-family:Garamond;
panose-1:2 2 4 4 3 3 1 1 8 3;}
@font-face
{font-family:"Bookman Old Style";
panose-1:2 5 6 4 5 5 5 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Times New Roman";
color:black;}
p.MsoBodyTextIndent, li.MsoBodyTextIndent, div.MsoBodyTextIndent
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.2in;
margin-bottom:.0001pt;
text-indent:.3in;
font-size:10.0pt;
font-family:"Times New Roman";
color:black;}
p.MsoBodyTextIndent2, li.MsoBodyTextIndent2, div.MsoBodyTextIndent2
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.15in;
margin-bottom:.0001pt;
text-indent:.3in;
font-size:10.0pt;
font-family:Garamond;
color:black;}
p.MsoBodyTextIndent3, li.MsoBodyTextIndent3, div.MsoBodyTextIndent3
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.25in;
margin-bottom:.0001pt;
text-indent:.25in;
font-size:10.0pt;
font-family:"Times New Roman";
color:black;}
p.MsoBlockText, li.MsoBlockText, div.MsoBlockText
{margin-top:0in;
margin-right:13.5pt;
margin-bottom:0in;
margin-left:.2in;
margin-bottom:.0001pt;
text-indent:.3in;
font-size:10.0pt;
font-family:"Times New Roman";
color:black;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
{page:Section1;}
--&gt;
/**/
</style>
</head>
<body lang="EN-US" >
<div class="Section1">
<p id="RES_0031_00_00001" class="MsoNormal" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:23.4pt">
<b><span style="font-size:16.5pt">1 DATA ENTRY</span></b></p>
<p id="RES_0031_00_00002" class="MsoNormal" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:.3in;text-indent:.25in">
<span style="font-size:9.5pt">Data entry refers to user actions
involving input of data to a computer, and computer responses to
such inputs. The simplest kind of data entry consists merely of
pointing at something -- selecting an item or designating a
position on a computer-generated display. In more complicated modes
of data entry, a user may have to control the format of data inputs
as well as their contents. Thus questions of format control in text
entry/editing and graphic interaction may properly be considered
questions of data entry.</span></p>
<p id="RES_0031_00_00003" class="MsoNormal" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:.3in;text-indent:.25in">
<span style="font-size:9.5pt">Note, however, that user inputs which
initiate or interrupt transactions -- such as command entries, or
control entries selected from a displayed menu or by function keys
-- pose rather different questions of design. Such control entries
are discussed in Section 3 of these guidelines.</span></p>
<p id="RES_0031_00_00004" class="MsoNormal" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:.3in;text-align:justify;text-indent:.25in">
<span style="font-size: 9.5pt">Data can be entered into a computer
in a variety of different ways. Users might designate position or
direction by pointing at a display. Users might enter numbers,
letters, or more extended textual material by keyed inputs, or in
some applications by spoken inputs. Data might be keyed into
displayed forms or tables, into constrained message formats, or as
free text. In graphic interaction users might draw pictures or
manipulate displayed graphic elements. These different types of
data entry all merit consideration here.</span></p>
<p id="RES_0031_00_00005" class="MsoNormal" style="margin-top:0in;margin-right:0in;margin-bottom:6.0pt; margin-left:.3in;text-indent:.25in">
<span style="font-size:9.5pt">The computer will also play a role in
the data entry process, guiding users who need help, checking data
entries to detect errors, and providing other kinds of data
processing aids. A designer of user interface software must be
concerned about computer processing logic as well as data input by
the user.</span></p>
</div>
</body>
</html>

What was happening is that the style sheet would only process the firt html that was opened. This behavior was occurring while using the built in xsl processor of XMLSPY. I canged to MSXML and worked perfectly. Problem solved. Thanks for your time.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top