Subject: RE: [xsl] Question: Change string to nodeset for dynamic xml lookup From: "Josh Canfield" <josh.canfield@xxxxxxxxxxxx> Date: Thu, 15 Jan 2004 10:38:53 -0800 |
You can't construct an xpath expression at run-time. http://www.dpawson.co.uk/xsl/sect2/nono.html#d1419e507 You could use an extension function such as http://www.exslt.org/dyn/functions/evaluate/ Hope this helps, Josh -----Original Message----- From: Ouen Worth [mailto:oworth@xxxxxxxxxxx] Sent: Thursday, January 15, 2004 10:10 AM To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Question: Change string to nodeset for dynamic xml lookup I have tried to find a solution to this and it seems to be that I need to use the xsl:key and key function, but I have had no luck Here is what I am trying to do so far without the key. I am trying to create an output xml that is formed by a xsl that references a xml that contains definition data for retrieving data from an external xml file. The reason for this is so that there is an easy to create xml definition file that can be created from csv - which can be maintained by xml illiterate personal - which is then used to validate external xml for business rule purposes. The value of the external element needs to be included in the output xml for this reason. However, the Value element always contains the value of the Xpath element and not the value of the element that the string in Xpath refers to in the external xml. <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:variable name="Order" select="document('Order.xml')/Order"/> <xsl:template match="/"> <Validate> <xsl:for-each select="StandardCheck/Definition"> <Field> <Requirement> <xsl:value-of select="Requirement"/> </Requirement> <XPath> <xsl:value-of select="XPath"/> </XPath> <Value> <xsl:apply-templates select="$Order"> <xsl:with-param name="XPath" select="XPath"/> </xsl:apply-templates> </Value> </Field> </xsl:for-each> </Validate> </xsl:template> <xsl:template match="Order"> <xsl:param name="XPath"></xsl:param> <xsl:value-of select="$XPath"/> </xsl:template> </xsl:stylesheet> <?xml version="1.0"?> <StandardCheck DocType="Order"> <Definition> <Requirement>M</Requirement> <XPath>/Order/OrderHeader/OrderIssueDate</XPath> </Definition> <Definition> <Requirement>R</Requirement> <XPath>/Order/OrderHeader/OrderNumber/BuyerOrderNumber</XPath> </Definition> </StandardCheck> <?xml version="1.0"?> <Order> <OrderHeader> <OrderNumber> <BuyerOrderNumber>4060001624</BuyerOrderNumber> </OrderNumber> <OrderIssueDate>20031205T08:52:13+02:00</OrderIssueDate> <OrderReferences> <AccountCode> <Reference> <RefNum>1000</RefNum> </Reference> </AccountCode> </OrderReferences> </OrderHeader> <Order> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Question: Change string to no, Ouen Worth | Thread | RE: [xsl] Using Extension Functions, Joshua Allen |
[xsl] Question: Change string to no, Ouen Worth | Date | Re: [xsl] Sort column in table, J.Pietschmann |
Month |