[xsl] Help with some XPATH questions

Subject: [xsl] Help with some XPATH questions
From: Vincenzo Menanno <enzo13@xxxxxxx>
Date: Thu, 28 Jul 2005 14:06:53 -0700
Hi there I need some real guru help here... 

I am a real novice here on this stuff... so be kind :)

I have an XML document that has a structure something like this... but inside the Layout elements there can be many other descendants called objects... some objects can be not directly under Layout but nested way beneath inside other elements... 

<FMPReport>
    <File>
        <LayoutCatalog>
            <Layout>
                <Object>
            <Layout>
        <LayoutCatalog>
    </File>
</FMPReport>

I want to be able to pull out individual items...

So for example I want to pull out all the Objects that have type elements with an attribute of 'Text' --- then I want to have another template process all the type elments with an attribute of 'Field' etc... etc... 


So far what I have is 

            <RESULTSET>
                <xsl:attribute name="FOUND">
                    <xsl:value-of select="count(//LayoutCatalog/Layout)"/>
                </xsl:attribute>
                <xsl:apply-templates select="//LayoutCatalog/Layout/descendant::Object[@type='text']"/>
            </RESULTSET>


I thought that this would work but it does not... this is the error I get:

Description: E Error in expression //LayoutCatalog/Layout/descendant::Object[@type='text']: Axis in pattern must be child or attribute

I guess what I don't understand this error - and I also don't really understand the role of

"<xsl:attribute name="FOUND">"

Then the "xsl:apply-templates select" that follows - I am under the impression that it just is something that follows, extends the found set in some way... 

Any help or advice would greatly be appreciated... Thanks

Vince

Below is a layout with possible text objects on there.
---------------------------------------------------------
<Layout id="1" name="Layout Objects" includeInMenu="True">
	<Table id="13631489" name="Layout Objects"/>
	<CustomMenuSet id="0" name=""/>
	<Options saveRecord="True" showFieldFrames="True"/>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="49151" fieldBorders="223">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>9</Font-size>
			<Face>256</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="128">
			<Justification>3</Justification>
		</ParagraphStyle>
		<NumFormat flags="0" charStyle="0" negativeStyle="1" currencySymbol=""
			thousandsSep="0" decimalPoint="0" negativeColor="#28BFD8"
			decimalDigits="-16385" trueString="" falseString=""/>
		<DateFormat format="191" charStyle="255" monthStyle="224" dayStyle="112"
			separator="49151">
			<DateElement>-1073750432</DateElement>
			<DateElement>-1073749920</DateElement>
			<DateElement>11545879</DateElement>
			<DateElement>-1073750432</DateElement>
		</DateFormat>
		<TimeFormat flags="439" charStyle="196" hourStyle="136" minsecStyle="0"
			separator="0" amString="" pmString="" ampmString=""/>
		<DrawStyle linePat="96" lineWidth="-65" lineColor="#FFDE60BF" fillPat="-1"
			fillEffect="-32" fillColor="#60BFFFDE"/>
		<AltLineStyle linePat="-32" lineWidth="0" lineColor="#980000BF"/>
	</ObjectStyle>
	<Object type="Text" flags="0" portal="-1" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top=" 25.000000" left=" 98.489258" bottom=" 38.000000"
			right="127.000000"/>
		<DrawStyle linePat="1" lineWidth="0" lineColor="#FFFFFF00" fillPat="1"
			fillEffect="0" fillColor="#FFFFFF00"/>
		<TextObj flags="0">
			<CharacterStyleVector>
				<Style>
					<Data>name</Data>
					<CharacterStyle mask="16183">
						<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
						<Font-size>9</Font-size>
						<Face>256</Face>
						<Color>#000000</Color>
					</CharacterStyle>
				</Style>
			</CharacterStyleVector>
			<ParagraphStyleVector>
				<Style>
					<Data>name</Data>
					<ParagraphStyle mask="0"> </ParagraphStyle>
				</Style>
			</ParagraphStyleVector>
		</TextObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>12</Font-size>
			<Face>0</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447"> </ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol="$"
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="Yes" falseString="No"/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
			<DateElementSep index="1">,&#32;</DateElementSep>
			<DateElementSep index="2">&#32;</DateElementSep>
			<DateElementSep index="3">,&#32;</DateElementSep>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="&#32;AM" pmString="&#32;PM" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Field" flags="0" portal="-1" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top=" 24.000000" left="138.000000" bottom=" 38.000000"
			right="391.000000"/>
		<FieldObj numOfReps="1" flags="32" inputMode="0" displayType="0">
			<Name>Layout&#32;Objects::name</Name>
			<DDRInfo>
				<Field name="name" id="1" repetition="1" maxRepetition="1"
					table="Layout&#32;Objects"/>
			</DDRInfo>
		</FieldObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>9</Font-size>
			<Face>256</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447">
			<Justification>3</Justification>
		</ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol=""
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="" falseString=""/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="" pmString="" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Text" flags="0" portal="-1" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top=" 43.000000" left=" 89.000000" bottom=" 56.000000"
			right="127.000000"/>
		<DrawStyle linePat="1" lineWidth="0" lineColor="#FFFFFF00" fillPat="1"
			fillEffect="0" fillColor="#FFFFFF00"/>
		<TextObj flags="0">
			<CharacterStyleVector>
				<Style>
					<Data>address</Data>
					<CharacterStyle mask="16183">
						<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
						<Font-size>9</Font-size>
						<Face>256</Face>
						<Color>#000000</Color>
					</CharacterStyle>
				</Style>
			</CharacterStyleVector>
			<ParagraphStyleVector>
				<Style>
					<Data>address</Data>
					<ParagraphStyle mask="0"> </ParagraphStyle>
				</Style>
			</ParagraphStyleVector>
		</TextObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>12</Font-size>
			<Face>0</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447"> </ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol="$"
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="Yes" falseString="No"/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
			<DateElementSep index="1">,&#32;</DateElementSep>
			<DateElementSep index="2">&#32;</DateElementSep>
			<DateElementSep index="3">,&#32;</DateElementSep>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="&#32;AM" pmString="&#32;PM" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Field" flags="0" portal="-1" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top=" 42.000000" left="138.000000" bottom=" 56.000000"
			right="391.000000"/>
		<FieldObj numOfReps="1" flags="32" inputMode="0" displayType="0">
			<Name>LO&#32;Outside::address</Name>
			<DDRInfo>
				<Field name="address" id="2" repetition="1" maxRepetition="1"
					table="LO&#32;Outside"/>
			</DDRInfo>
		</FieldObj>
	</Object>
	<Object type="Portal" flags="134217728" portal="-1" rotation="0">
		<Bounds top=" 84.000000" left="144.000000" bottom="165.000000"
			right="385.000000"/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltFillStyle fillPat="1" fillEffect="0" fillColor="#FFFFFF00"/>
		<PortalObj portalFlags="16" numOfRows="5" initialRow="1">
			<TableAliasKey>LO&#32;Outside</TableAliasKey>
			<FieldList>
				<Field id="2" name="address" table="LO Outside"/>
				<Field id="1" name="id" table="LO Outside"/>
			</FieldList>
		</PortalObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>12</Font-size>
			<Face>0</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447"> </ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol="$"
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="Yes" falseString="No"/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
			<DateElementSep index="1">,&#32;</DateElementSep>
			<DateElementSep index="2">&#32;</DateElementSep>
			<DateElementSep index="3">,&#32;</DateElementSep>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="&#32;AM" pmString="&#32;PM" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Field" flags="0" portal="4" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top=" 85.000000" left="145.000000" bottom=" 99.000000"
			right="263.500000"/>
		<FieldObj numOfReps="1" flags="32" inputMode="0" displayType="0">
			<Name>LO&#32;Outside::address</Name>
			<DDRInfo>
				<Field name="address" id="2" repetition="1" maxRepetition="1"
					table="LO&#32;Outside"/>
			</DDRInfo>
		</FieldObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>12</Font-size>
			<Face>0</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447"> </ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol="$"
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="Yes" falseString="No"/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
			<DateElementSep index="1">,&#32;</DateElementSep>
			<DateElementSep index="2">&#32;</DateElementSep>
			<DateElementSep index="3">,&#32;</DateElementSep>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="&#32;AM" pmString="&#32;PM" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Field" flags="0" portal="4" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top=" 85.000000" left="264.500000" bottom=" 99.000000"
			right="383.000000"/>
		<FieldObj numOfReps="1" flags="32" inputMode="0" displayType="0">
			<Name>LO&#32;Outside::id</Name>
			<DDRInfo>
				<Field name="id" id="1" repetition="1" maxRepetition="1"
					table="LO&#32;Outside"/>
			</DDRInfo>
		</FieldObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>9</Font-size>
			<Face>256</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447">
			<Justification>3</Justification>
		</ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol="$"
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="Yes" falseString="No"/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
			<DateElementSep index="1">,&#32;</DateElementSep>
			<DateElementSep index="2">&#32;</DateElementSep>
			<DateElementSep index="3">,&#32;</DateElementSep>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="&#32;AM" pmString="&#32;PM" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Text" flags="0" portal="-1" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top="187.000000" left="142.000000" bottom="200.000000"
			right="190.000000"/>
		<DrawStyle linePat="1" lineWidth="0" lineColor="#FFFFFF00" fillPat="1"
			fillEffect="0" fillColor="#FFFFFF00"/>
		<TextObj flags="8">
			<CharacterStyleVector>
				<Style>
					<Data>&lt;&lt;name&gt;&gt;</Data>
					<CharacterStyle mask="16183">
						<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
						<Font-size>9</Font-size>
						<Face>256</Face>
						<Color>#000000</Color>
					</CharacterStyle>
				</Style>
			</CharacterStyleVector>
			<ParagraphStyleVector>
				<Style>
					<Data>&lt;&lt;name&gt;&gt;</Data>
					<ParagraphStyle mask="0"> </ParagraphStyle>
				</Style>
			</ParagraphStyleVector>
			<FieldList>
				<Field id="1" name="name" table="Layout Objects"/>
			</FieldList>
		</TextObj>
	</Object>
	<ObjectStyle id="0" fontHeight="12" graphicFormat="5" fieldBorders="0">
		<CharacterStyle mask="16183">
			<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
			<Font-size>9</Font-size>
			<Face>256</Face>
			<Color>#000000</Color>
		</CharacterStyle>
		<ParagraphStyle mask="447">
			<Justification>3</Justification>
		</ParagraphStyle>
		<NumFormat flags="2304" charStyle="0" negativeStyle="0" currencySymbol="$"
			thousandsSep="44" decimalPoint="46" negativeColor="#DD000000"
			decimalDigits="2" trueString="Yes" falseString="No"/>
		<DateFormat format="0" charStyle="0" monthStyle="0" dayStyle="0" separator="47">
			<DateElement>3</DateElement>
			<DateElement>6</DateElement>
			<DateElement>1</DateElement>
			<DateElement>8</DateElement>
			<DateElementSep index="1">,&#32;</DateElementSep>
			<DateElementSep index="2">&#32;</DateElementSep>
			<DateElementSep index="3">,&#32;</DateElementSep>
		</DateFormat>
		<TimeFormat flags="143" charStyle="0" hourStyle="0" minsecStyle="1"
			separator="58" amString="&#32;AM" pmString="&#32;PM" ampmString=""/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
		<AltLineStyle linePat="7" lineWidth="1" lineColor="#0"/>
	</ObjectStyle>
	<Object type="Text" flags="0" portal="-1" rotation="0">
		<StyleId>0</StyleId>
		<Bounds top="217.000000" left="143.000000" bottom="230.000000"
			right="256.000000"/>
		<DrawStyle linePat="1" lineWidth="0" lineColor="#FFFFFF00" fillPat="1"
			fillEffect="0" fillColor="#FFFFFF00"/>
		<TextObj flags="8">
			<CharacterStyleVector>
				<Style>
					<Data>&lt;&lt;LO&#32;Outside::address&gt;&gt;</Data>
					<CharacterStyle mask="16183">
						<Font-family codeSet="Roman" fontId="0">Helvetica</Font-family>
						<Font-size>9</Font-size>
						<Face>256</Face>
						<Color>#000000</Color>
					</CharacterStyle>
				</Style>
			</CharacterStyleVector>
			<ParagraphStyleVector>
				<Style>
					<Data>&lt;&lt;LO&#32;Outside::address&gt;&gt;</Data>
					<ParagraphStyle mask="0"> </ParagraphStyle>
				</Style>
			</ParagraphStyleVector>
			<FieldList>
				<Field id="2" name="address" table="LO Outside"/>
			</FieldList>
		</TextObj>
	</Object>
	<Object type="Line" flags="12288" portal="-1" rotation="0">
		<Bounds top="263.792908" left="149.792908" bottom="265.207123"
			right="397.207092"/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
	</Object>
	<Object type="Rect" flags="0" portal="-1" rotation="0">
		<Bounds top="276.000000" left="150.000000" bottom="337.000000"
			right="241.000000"/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
	</Object>
	<Object type="RRect" flags="0" portal="-1" rotation="0">
		<Bounds top="276.000000" left="264.000000" bottom="337.000000"
			right="385.000000"/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
	</Object>
	<Object type="Oval" flags="0" portal="-1" rotation="0">
		<Bounds top="354.000000" left="156.000000" bottom="433.000000"
			right="241.000000"/>
		<DrawStyle linePat="2" lineWidth="1" lineColor="#0" fillPat="1" fillEffect="0"
			fillColor="#FFFFFF00"/>
	</Object>
</Layout>

Current Thread