Click here to Skip to main content
15,883,971 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralRe: XML validation through XSD Pin
DavidNohejl28-Dec-04 9:05
DavidNohejl28-Dec-04 9:05 
GeneralRe: XML validation through XSD Pin
Het210931-Dec-04 21:48
Het210931-Dec-04 21:48 
GeneralW3C XML standards Pin
Nosheen Iqbal21-Dec-04 16:20
Nosheen Iqbal21-Dec-04 16:20 
GeneralI want XML to draw the network topology Pin
Mohammed Aijaz Mohiuddin21-Dec-04 6:00
Mohammed Aijaz Mohiuddin21-Dec-04 6:00 
GeneralRe: I want XML to draw the network topology Pin
DavidNohejl21-Dec-04 8:29
DavidNohejl21-Dec-04 8:29 
GeneralSkip blocks of nodes with XSL Pin
Milby00720-Dec-04 0:22
Milby00720-Dec-04 0:22 
GeneralRe: Skip blocks of nodes with XSL Pin
Milby00720-Dec-04 3:13
Milby00720-Dec-04 3:13 
GeneralRe: Skip blocks of nodes with XSL Pin
Milby00720-Dec-04 23:46
Milby00720-Dec-04 23:46 
Just incase anyone would find this helpful, i've got it working. it's not really how i wanted it to be written, so if anyone can see a better way of doing it then please say. i've also added another special document control called a dataname (basically a variable), so by adding text to the document enclosed in <dataname> tags with a reference to that and its value in the merge-data.xml file (e.g. <dataname ref="&lt;&lt;CFNAME&gt;&gt;">RICH</dataname> then you can effectively merge data into the document. the stylsheet code is copied below:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sdp="http://www.sectornet.co.uk/2004/DocPro">
	<xsl:output method="html"/>
	<xsl:variable name="mergeData" select="document('merge-data.xml')//docpro-print-entry/dataset"/>
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<xsl:template match="/">
		<html>
			<head>
				<title>condition test output.</title>
			</head>
			<body>
				<center>
					<h1>Condition Test.</h1>
				</center>
				<xsl:apply-templates select="doc/page/content/para[1]"/>
			</body>
		</html>
	</xsl:template>
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<xsl:template match="para">
		<p>
			<xsl:apply-templates/>
		</p>
	</xsl:template>
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<xsl:template match="text">
		<xsl:choose>
			<xsl:when test="count(self::*/*) &gt; 0">
				<!-- we have controls in this block -->
				<xsl:apply-templates/>
			</xsl:when>
			<xsl:otherwise>
				<!-- output text and move on to next block -->
				<xsl:value-of select="."/>
				<xsl:apply-templates select="ancestor::*/following-sibling::*[1]"/>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<xsl:template match="dataname">
		<xsl:param name="sourceContext" select="$mergeData"/>
		<xsl:variable name="curNode" select="."/>
		
		<xsl:value-of select="$sourceContext//dataname[@ref = $curNode]"/>
		
		<!-- move on to next block -->
		<xsl:apply-templates select="ancestor::*/following-sibling::*[1]"/>
	</xsl:template>
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<!-- ++++++++++++++++++++++++++++++++++ -->
	<xsl:template match="condition">
		<xsl:variable name="curNode" select="."/>
		
		<xsl:choose>
			<xsl:when test="$curNode/@eval = 'ELSE'">
				<!-- process else statement -->
				<xsl:variable name="prevIfNode" select="$mergeData/condition[@ref = substring-after($curNode, '&lt;&lt;ELSE&gt;&gt;')]"/>
				
				<xsl:choose>
					<xsl:when test="$prevIfNode != 'TRUE'">
						<!-- continue through the block -->
						<xsl:apply-templates select="ancestor::*/following-sibling::*[1]"/>
					</xsl:when>
					<xsl:otherwise>
						<!-- go to end tag -->
						<xsl:apply-templates select="ancestor::*/following::*/condition[text() = concat('&lt;&lt;ENDIF&gt;&gt;', $prevIfNode/@ref)]"/>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="$curNode/@eval != 'END'">
				<!-- process if statement -->
				<xsl:variable name="curIfNode" select="$mergeData/condition[@ref = $curNode]"/>
				
				<xsl:choose>
					<xsl:when test="$curIfNode = 'TRUE'">
						<!-- continue through the block -->
						<xsl:apply-templates select="ancestor::*/following-sibling::*[1]"/>
					</xsl:when>
					<xsl:otherwise>
						<xsl:choose>
							<xsl:when test="ancestor::*/following::*/condition/text() = concat('&lt;&lt;ELSE&gt;&gt;', $curNode)">
								<!-- go to else tag -->
								<xsl:apply-templates select="ancestor::*/following::*/condition[text() = concat('&lt;&lt;ELSE&gt;&gt;', $curNode)]"/>
							</xsl:when>
							<xsl:otherwise>
								<!-- go to end tag -->
								<xsl:apply-templates select="ancestor::*/following::*/condition[text() = concat('&lt;&lt;ENDIF&gt;&gt;', $curNode)]"/>
							</xsl:otherwise>
						</xsl:choose>
					</xsl:otherwise>
				</xsl:choose>
			</xsl:when>
			<xsl:when test="$curNode/@eval = 'END'">
				<!-- continue past the block -->
				<xsl:apply-templates select="ancestor::*/following-sibling::*[1]"/>
			</xsl:when>
		</xsl:choose>
	</xsl:template>
	
</xsl:stylesheet>

GeneralBasic XML Pin
sharkbait16-Dec-04 3:55
sharkbait16-Dec-04 3:55 
GeneralXslt generated XML string format problem. Pin
titabonbon15-Dec-04 19:27
titabonbon15-Dec-04 19:27 
GeneralRe: Xslt generated XML string format problem. Pin
DavidNohejl17-Dec-04 12:17
DavidNohejl17-Dec-04 12:17 
GeneralRe: Xslt generated XML string format problem. Pin
titabonbon22-Dec-04 15:25
titabonbon22-Dec-04 15:25 
GeneralRe: Xslt generated XML string format problem. Pin
DavidNohejl23-Dec-04 0:06
DavidNohejl23-Dec-04 0:06 
GeneralRe: Xslt generated XML string format problem. Pin
titabonbon23-Dec-04 12:58
titabonbon23-Dec-04 12:58 
GeneralRe: Xslt generated XML string format problem. Pin
DavidNohejl23-Dec-04 13:28
DavidNohejl23-Dec-04 13:28 
GeneralRe: Xslt generated XML string format problem. Pin
titabonbon26-Dec-04 12:14
titabonbon26-Dec-04 12:14 
GeneralRe: Xslt generated XML string format problem. Pin
DavidNohejl26-Dec-04 14:16
DavidNohejl26-Dec-04 14:16 
QuestionDoes anybody know why XmlAttribute has ChildNodes property? Pin
DavidNohejl15-Dec-04 11:46
DavidNohejl15-Dec-04 11:46 
AnswerRe: Does anybody know why XmlAttribute has ChildNodes property? Pin
J4amieC20-Dec-04 3:09
J4amieC20-Dec-04 3:09 
GeneralRe: Does anybody know why XmlAttribute has ChildNodes property? Pin
DavidNohejl20-Dec-04 3:46
DavidNohejl20-Dec-04 3:46 
GeneralAsp.net - Xml Pin
Anonymous13-Dec-04 23:54
Anonymous13-Dec-04 23:54 
GeneralRe: Asp.net - Xml Pin
DavidNohejl14-Dec-04 2:15
DavidNohejl14-Dec-04 2:15 
GeneralConverting xsd via xsl to code Pin
mgaerber13-Dec-04 7:36
mgaerber13-Dec-04 7:36 
General.NET support for XSLT 2.0 and XPath 2.0 Pin
Jim Taylor12-Dec-04 23:33
Jim Taylor12-Dec-04 23:33 
GeneralRe: .NET support for XSLT 2.0 and XPath 2.0 Pin
Philip Fitzsimons13-Dec-04 1:30
Philip Fitzsimons13-Dec-04 1:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.