Jelajahi Sumber

+ idea to parse related feature dita file

Piotr Labudda 6 tahun lalu
induk
melakukan
03f6754dce

+ 7 - 1
SE/se-lib/Route/Test/ConvertDitaRelatedFeature.php

@@ -3,13 +3,19 @@
 Lib::loadClass('RouteBase');
 Lib::loadClass('XML');
 
+// @see Route_Test_XslRecurse for example use of php function inside xsl
+// - TODO: input file should have another extension, it is not correct dita file, it has tags RelatedFeature
+// IDEA: make object (DitaRelatedFeatureParser) with state to parse input file (dita RelatedFeature tmpl)
+// - at the beginning od tag RelatedFeature run php function to set current xpath in Parse object
+// - at the end od tag RelatedFeature run php function to unset current xpath in Parse object (go up in doc tree)
+
 class Route_Test_ConvertDitaRelatedFeature extends RouteBase {
 
 	function defaultAction() {
 		UI::layout( [ $this, 'defaultView' ], [ 'showMenu' => false ] );
 	}
 	function defaultView() {
-		$inputPath = APP_PATH_ROOT . DS . 'schema/ant-url_action/default_db.in7_dziennik_koresp/test-druk/IN7_DZIENNIK_KORESP.dita';
+		$inputPath = APP_PATH_ROOT . DS . 'schema/ant-url_action/default_db.in7_dziennik_koresp/test-druk/IN7_DZIENNIK_KORESP.dita'; // TODO: it is not correct dita file - has tags RelatedFeature
 		$inputBody = file_get_contents($inputPath);
 		DBG::nicePrint(htmlspecialchars($inputBody), "input");
 		DBG::nicePrint(null, "memory_get_usage: " . round(memory_get_usage() / 1024) . " KB");

+ 23 - 23
SE/se-lib/Route/Test/XslRecurse.php

@@ -12,48 +12,48 @@ class Route_Test_XslRecurse extends RouteBase {
 		Lib::loadXslFunction('testHtmlContent');
 		$xml = "
 			<root>
-			 <item typeName=\"default_db:TEST_PERMS\">
-			  <featureId>TEST_PERMS.1</featureId>
-			 </item>
-			 <item typeName=\"default_db:TEST_PERMS\">
-			  <featureId>TEST_PERMS.99999</featureId>
-			 </item>
-			 <item typeName=\"default_db__x3A__TEST_PERMS:TestPermsAnt\">
-			  <featureId>TestPermsAnt.1</featureId>
-			 </item>
+				<item typeName=\"default_db:TEST_PERMS\">
+					<featureId>TEST_PERMS.1</featureId>
+				</item>
+				<item typeName=\"default_db:TEST_PERMS\">
+					<featureId>TEST_PERMS.99999</featureId>
+				</item>
+				<item typeName=\"default_db__x3A__TEST_PERMS:TestPermsAnt\">
+					<featureId>TestPermsAnt.1</featureId>
+				</item>
 			</root>
 		";
 		$xsl = '<?xml version="1.0" encoding="UTF-8"?>';
 		$xsl .= '
 			<xsl:stylesheet version="1.0"
-			     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
-			     xmlns:php="http://php.net/xsl">
+				xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+				xmlns:php="http://php.net/xsl">
 			<xsl:output method="html" encoding="utf-8" indent="yes"/>
-			 <xsl:template match="root">
-			  <html><body>
-			    <h2>Items</h2>
-			    <table class="table table-bordered">
+			<xsl:template match="root">
+			<html><body>
+				<h2>Items</h2>
+				<table class="table table-bordered">
 						<thead>
 							<tr>
 								<th>featureId</th>
 								<th>item</th>
 							</tr>
 						</thead>
-			    <xsl:for-each select="item">
-			      <tr>
+				<xsl:for-each select="item">
+				<tr>
 							<td><xsl:value-of select="featureId"/></td>
 							<td><pre>
-				        <xsl:copy-of select="php:function(\'testFetchWfs\', string(@typeName), string(featureId))/node()"/>
-				      </pre></td>
+						<xsl:copy-of select="php:function(\'testFetchWfs\', string(@typeName), string(featureId))/node()"/>
+					</pre></td>
 						</tr>
-			    </xsl:for-each>
-			    </table>
+				</xsl:for-each>
+				</table>
 
 					<h3>Test function to get xml content from php function</h3>
 					<xsl:copy-of select="php:function(\'testHtmlContent\', \'test-arg-1-from-xsl\', \'test-arg-2-from-xsl\')/node()"/>
 
-			  </body></html>
-			 </xsl:template>
+			</body></html>
+			</xsl:template>
 			</xsl:stylesheet>
 		';
 		$xmldoc = new DOMDocument;