Q

How to find all the List elements that contain a particular value using XPath and XSLT?

I'm not sure if this is an XSL or XPath question. It has to do with the type. In the schema I have...

a simple type:

   <xs:simpleType name="doubleListType">
     <xs:list itemType="xs:int" />
   </xs:simpleType>

I also have an element: <xs:element name="root"> <xs:complexType> <xs:all> <xs:element name="Lists" minOccurs="0"> <xs:complexType> <xs:sequence> <xs:element name="L" type="intListType" maxOccurs="unbounded" /> </xs:sequence> </xs:complexType> </xs:element> </xs:all> </xs:complexType> </xs:element>

What I want is to be able to find all the List <L> elements that contain a particular value. I can seach for element values, but not values within a list. I would like to output this to XML, which I think, means I cannot use script commands, but I may be wrong there! Any help would be fantasic!!
You can do this with XSLT and XPath (which is embedded into XSLT) using something like this:


<xsl:template match="L">
         <xsl:value-of select="."/>
         <xsl:if test="test for value goes here">
                 <xsl:text>Output the number here</xsl:text>
         </xsl:if>
</xsl:template>

This was last published in June 2002

Dig Deeper on XML and XML schema

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchSoftwareQuality

SearchCloudApplications

SearchAWS

TheServerSide

SearchWinDevelopment

Close