473,782 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading Code/Description lookup via inline XSLT

23 New Member
I've been trying to piece together various code snippets to create a lookup table inside my xslt without the need for a supplemental xml file. Here is what I have so far. As of now, it does not return anything in the output. I would love to be able to query the xref:factor table to retrieve the value of xref:factor/lookup

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "*">]> 
  3. <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version="1.0"
  4.     xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
  5.     xmlns:xref="http://www.dummy.com/xref"
  6.     extension-element-prefixes="xref">
  7.  
  8.     <xsl:output method="html" version="3.0" encoding="iso-8859-1" indent="yes"/>
  9.  
  10.     <xref:factor>
  11.         <lookup factorcode="K">Test 1</lookup>
  12.         <lookup factorcode="I">Test 2</lookup>
  13.         <lookup factorcode="B">Test 3</lookup>
  14.         <lookup factorcode="G">Test 4</lookup>
  15.     </xref:factor>
  16.  
  17.     <xsl:key name="factor" match="xref:factor/lookup" use="@factorcode" />
  18.     <xsl:variable name="factors" select='document("")//xref:factor' />
  19.  
  20.     <xsl:template match="/CREDITDATA">
  21.         <html>
  22.             <head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"/></head>
  23.             <body>
  24.                 <xsl:for-each select="scoreinformation">
  25.                     <xsl:variable name="origfactor" select="normalize-space(factor1)"/>
  26.                     <xsl:for-each select='$factors'>
  27.                         <xsl:value-of select='key("factor", $origfactor)'/>
  28.                     </xsl:for-each>
  29.                 </xsl:for-each>
  30.             </body>
  31.         </html>
  32.     </xsl:template>
  33. </xsl:stylesheet>
  34.  
Here is a sample of the xml file:

Expand|Select|Wrap|Line Numbers
  1. <CREDITDATA>
  2.     <scoreinformation ID="1">
  3.         <score>0519</score> 
  4.         <factor1>K</factor1> 
  5.         <factor2>I</factor2> 
  6.         <factor3>B</factor3> 
  7.         <factor4>G</factor4> 
  8.         <model>B</model> 
  9.     </scoreinformation>
  10. </CREDITDATA>
  11.  
Jan 7 '09
11 4004
jkmyoung
2,057 Recognized Expert Top Contributor
I think you use an XmlResolver: specificially XmlUrlResolver
XslTransform.Tr ansform Method (IXPathNavigabl e, XsltArgumentLis t, XmlWriter, XmlResolver) (System.Xml.Xsl )
XmlUrlResolver Class (System.Xml)
Jan 12 '09 #11
ianoble
23 New Member
Shoot, that was so simple! I'm still on .net 1.1, so I didn't think to look at the XmlUrlResolver class, but that did the trick.

Thank you again for your help!
Jan 12 '09 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2775
by: Xtr | last post by:
Hello, Is it possible, using xsl, to indent most tags, but preserve the position of tags that are inline (surrounded by text)? For example, given the following,: <text><p>text<b>text</b></p></text> <text><p>text<b>text</b></p></text>
4
4305
by: Adrian Charteris | last post by:
Hi I'm currently trying to use a lookup table for converting one xml doc to another using a XSLT transformation. Ideally I would like my first xml doc to be converted to my second xml doc below. All that I want is to replace node names with a matching value in the lookup table and place the result into an field attribute pair: Example: id to be renamed instrument_id thus <id type="master">asset #132</id> becomes <field...
1
1223
by: amessimon | last post by:
Hi I need to read from an XML document formatted in this manner <?xml version="1.0"?> <result> <book> <title>A new book</title> <url>http://www.newbookstore.co.uk</url> <description>perspiciatis unde omnis iste natus error sit voluptatem
4
3516
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I click a button on a pop-up window the javascript for that button click does a 'button.form.submit'. On the Server side there is a Button click event for this button, but for some reason it no longer fires. It worked fine before and everything...
3
2429
by: jbsfe | last post by:
I have "Spilt" my database and the "lookup" and "seek" methods that previously worked, no longer do. I have learnd from reviewing the posts that the "lookup" and "Seek" methods cannot be used on linked tables and that you cannot set an "index" for a linked table. What I don't know how to do, is revise my code to complete the same tasks as it it did before I split the database. I'm sure the problem lies is this block of code: 'Define...
40
2805
by: GTi | last post by:
Is there any source code documentation tools available for Visual Studio 2005 ? I have created a LIB that must be documented. Must I do it by hand or is it some kind of tools to pre document my source code?
4
1409
by: J.D. | last post by:
Hello, I am working on a client project and they have a connection to a catalog system that passes data back and forth as xml over http The format of the data is as follow(s) > <?xml version="1.0"?> > > <customer-redemption>
18
2087
by: yinglcs | last post by:
Hi, I have a newbie XSLT question. I have the following xml, and I would like to find out the children of feature element in each 'features' element. i.e. for each <featuresI would like to look up what each feature depends on and gerenate a text file. For example, in the following file, I would like to find out feature A depends on A1 and A2 and feature B depends on B1 and B2. And write that to a text file.
11
6110
by: J_Zanetti | last post by:
Hello everybody, In my applications I've a ton of scripts that use remote XML file to fill forms and evaluate contents; In these scripts I always use the method SelectNode (that, with some workaround, works fine also in Mozilla). I've just found out that this method doesnt work in Safari browser, therefore my applications are not usable by this browser. Can anyone provide me any solution or workaround to be able to read XML files in...
0
9641
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5378
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3643
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.