|
|||||||
New to SitePoint Forums? Register here for free!
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
Do or do not, there is no try
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Nov 2001
Location: The Central Plains
Posts: 3,230
|
i have this in an XSL file:
Code:
<xsl:if test="position() > 1 and position() < 3" > |
|
|
|
|
|
#2 |
|
SitePoint Addict
![]() ![]() ![]() Join Date: Nov 2005
Location: Moss, Norway.
Posts: 280
|
First of all, note that XPath is the foundation for XSLT, so all the functionality and functions from XPath are available within XSLT. In addition XSLT has its own functions and extensions. Since you use the XPath function position(), you should be able to use the XPath operators <=, >= pluss the bolean operator and directly in your test if it is a valid XPath statement. If it is a predicate, it should be enclosed in [].
Generally you use this axis::node test [predicats] structure while filtering node sets. So you need to know the following concepts to perform tests:
Example filtering from the root node (document node in XPath 2.0). /*/NodeName1/NodeName2/[position() >= 1 and position() <= 3] Example of a more advanced filtering based on attributes and an XPath function: /*/*[local-name()="MyAttribute"]/*/*[position() >= 1 and position() <= 3] By combining XPath, XPointer and XInclude, it should also be possible to filter fragments of external documents that can be embedded into your own documents without using any external script or programming language. Example: You have an external file external.xml with the following structure: <myelement1 xmlns=xi="http//www.w3.org/2001/XInclude"> <myelement2 xml:id="myID"> ....................................... </myelement1> You can then access myelement2 with the myID id in external.xml like this: <myelement1 xmlns=xi="http//www.w3.org/2001/XInclude"> <xi:include href="external.xml" parse "xml" xpointer="xpointer(id('myID'))"/> <xi:fallback> Broken link or external server down ... </xi:fallback> </xi:include> </myelement1> Note: One advantage with external streaming parsers, is that the memory usage is much lesser than for tree based parsers that operate on the node tree in memory. So if memory usage is critical, that is an argument for using stream based parsers like SAX XML or XMLReader. Last edited by kgun; Dec 6, 2007 at 06:04. |
|
|
|
|
|
#3 |
|
Do or do not, there is no try
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Nov 2001
Location: The Central Plains
Posts: 3,230
|
woah! i have some reading to do.
thanks for the replay Kjell... |
|
|
|
![]() |
| Bookmarks |
«
Previous Thread
|
Next Thread
»
| Thread Tools | |
| Display Modes | |
|
|
|
All times are GMT -7. The time now is 14:25.









Hybrid Mode
