how do i create subset and union in XPath Query

Hi Friends,

I need a XPath query, whcih ll return me subset of data....
check below xml stream

<label id="MyExpenseDetails_lbl" xlink:role="terseLabel">Short Expense
Details</label>
<label id="MyExpenseDetails_lbl" xlink:role="displayLabel">Expense
Details</label>
<label id="InternalExpense_lbl" xlink:role="displayLabel">Internal
Expense</label>
<label id="ExternalExpense_lbl" xlink:role="terseLabel">Short External
Expense</label>

See above xml data having 4 label elements out of which 3 different IDs
and 2 different role.
MyExpenseDetails_lbl contain all 2 role, InternalExpense_lbl having
displayLabel and ExternalExpense_lbl having terseLabel

Now i want such XPath query or XQL command that return me collection of
label.
if user pass "terseLabel" label then label with role = "terseLabel"
should be return and the other one "InternalExpense_lbl" should also
return.

If user pass "displayLabel" label then label with only role =
"displayLabel" should be return.

Cond1: role = "terseLabel"
MyExpenseDetails_lbl (Short Expense Details) (only one record with role
= terseLabel )
InternalExpense_lbl (Internal Expense)
ExternalExpense_lbl (Short External Expense)

Cond2: role = "displayLabel"
MyExpenseDetails_lbl (Expense Details) (only one record with role =
displayLabel )
InternalExpense_lbl (Internal Expense)

There r also other more label roles , so i need it using XPath / XQL
query not by any hard coding

I tried below XPath Query but it's returning all 4 labels and i only
need as per my requirements. I mean if other label not exist for any
label then the default one i.e displayLabel should taken.

default:label[@xml:lang and  @xlink:role=("terseLabel" or
"displayLabel")]

Thanks in advance
Regards
Rushikesh

0
10/26/2005 12:36:54 PM
dotnet.xml 7266 articles. 0 followers. Follow

3 Replies
327 Views

Similar Articles

[PageSpeed] 55

I guess the big question is:

how is the user "passing" the required parameters ?

via a VBScript or JScript ?

via XSLT ?

I'm not familiar with XQL, but there are a few ways to pass parameters
and have them used in XPath, depending on the method you choose.

0
Gadrin (3)
10/27/2005 8:51:10 PM
Hi,

I m passing it from ASP.NET code (C# application)...but it doesn't
matter....I am only interested in XPath Query...
Bcoz we have one class XMLDocument in which i have to pass a valid
XPath Query and that function ll return me set of XMLNodes...

currently i m passing below xpath string and that function is returning
me all 4 records which i don't required....
default:label[@xml:lang and  @xlink:role=("terseLabel" or
"displayLabel")] 

Thanks & Regards
Rushikesh

0
10/28/2005 3:46:45 AM
This is from the MS XML 4.0 SDK.

You can pass a parameter to an XSL file and have the XSL retrieve the
nodes you
want.

This way you can supply the XML, the XSL and the parameter and it'll
return the
HTML (or output) which you can then response.write to the page.

Example

var xslt = new ActiveXObject("Msxml2.XSLTemplate.4.0");
var xslDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
var xslProc;
xslDoc.async = false;
xslDoc.resolveExternals = false;
xslDoc.load("sample.xsl");
xslt.stylesheet = xslDoc;
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode <> 0) {
   var myErr = xmlDoc.parseError;
   alert("You have error " + myErr.reason);
} else {
   xslProc = xslt.createProcessor();
   xslProc.input = xmlDoc;
   xslProc.addParameter("param1", "Hello");
   xslProc.transform();
   alert(xslProc.output);
}
File Name: Sample.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
   <xsl:output method="html"/>
   <xsl:param name="param1"/>
  <xsl:template match="/">
      The parameter value was: <xsl:value-of select="$param1"/>
  </xsl:template>
</xsl:stylesheet>
[Visual Basic]
Visual Basic Syntax
objXSLProcessor.addParameter(baseName, parameter, namespaceURI)
Parameters
baseName
The name that will be used inside the style sheet to identify the
parameter context.
parameter
A number, Boolean, string, IXMLDOMNodeList, or IXMLDOMNode. Passing in
a single node will produce a node list that contains one node
(shortcut). To remove a parameter previously added to the processor,
provide a value of Empty or Null instead. This acts as a signal to the
processor to remove any previously added parameter of the same name.
namespaceURI (optional)
An optional namespace.
Example
Dim xslt As New Msxml2.XSLTemplate40
Dim xslDoc As New Msxml2.FreeThreadedDOMDocument40
Dim xmlDoc As New Msxml2.DOMDocument40
Dim xslProc As IXSLProcessor
xslDoc.async = False
xslDoc.resolveExternals = False
xslDoc.Load "sample.xsl"
Set xslt.stylesheet = xslDoc
xmlDoc.async = False
xmlDoc.resolveExternals = False
xmlDoc.Load "books.xml"
If (xmlDoc.parseError.errorCode <> 0) Then
   Dim myErr
   Set myErr = xmlDoc.parseError
   MsgBox("You have error " & myErr.reason)
Else
   Set xslProc = xslt.createProcessor()
   xslProc.input = xmlDoc
   xslProc.addParameter "param1", "Hello"
   xslProc.Transform
   MsgBox xslProc.output
End If
File Name: Sample.xsl

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
   <xsl:output method="html"/>
   <xsl:param name="param1"/>
  <xsl:template match="/">
      The parameter value was: <xsl:value-of select="$param1"/>
  </xsl:template>
</xsl:stylesheet>
[C/C++]
C/C++ Syntax
HRESULT addParameter (BSTR baseName, VARIANT parameter, BSTR
namespaceURI);
Parameters
baseName [in]
The name that will be used inside the style sheet to identify the
parameter context.
parameter [in]
A number, Boolean, string, node list, or node. Passing in a single node
will produce a node list that contains one node (shortcut). To remove a
parameter previously added to the processor, you can pass a value of
VT_EMPTY, VT_NULL, or a NULL IDispatch or IUnknown instead. This acts
as a signal to the processor to remove any previously added parameter
of the same name.
namespaceURI [in, optional]
An optional namespace.
C/C++ Return Values
E_FAIL if readyState is READYSTATE_INTERACTIVE.

Example
#include "stdio.h"

#import <msxml4.dll>
using namespace MSXML2;

int checkParseError(IXMLDOMParseErrorPtr pError);
void dump_com_error(_com_error &e);


int main(int argc, char* argv[])
{

   CoInitialize(NULL);
   HRESULT hr;

   try{

      BOOL bResult = FALSE;
      short sResult = FALSE;


      IXMLDOMDocument2Ptr pStyleSheet=NULL;
      IXSLTemplatePtr pIXSLTemplate=NULL;
      IXSLProcessorPtr pXSLProcessor=NULL;

      hr = pIXSLTemplate.CreateInstance(__uuidof(XSLTemplate40));


hr=pStyleSheet.CreateInstance(__uuidof(FreeThreadedDOMDocument40));
      pStyleSheet->async = VARIANT_FALSE;
      pStyleSheet->resolveExternals = VARIANT_FALSE;
      hr=pStyleSheet->load("c:\\samplexsl.xml");
      //check on the parser error
      if(hr!=VARIANT_TRUE)
      {
         return checkParseError(pStyleSheet->parseError);
      }

      pIXSLTemplate->stylesheet = pStyleSheet.GetInterfacePtr();
      pXSLProcessor =  pIXSLTemplate->createProcessor();

      IXMLDOMDocumentPtr   pInputDoc;

      hr = pInputDoc.CreateInstance(__uuidof(DOMDocument40));
      pInputDoc->async = VARIANT_FALSE;
      pInputDoc->resolveExternals = FALSE;
      hr = pInputDoc->load("c:\\sampleXSLWithParam.xml");
      //check on the parser error
      if(hr!=VARIANT_TRUE)
      {
         return checkParseError(pInputDoc->parseError);
      }

      pInputDoc->async = VARIANT_FALSE;
      pInputDoc->resolveExternals = FALSE;
      pXSLProcessor->input = pInputDoc.GetInterfacePtr();

      hr=pXSLProcessor->addParameter("param1", "Hello", "");

      VARIANT_BOOL vtRet = pXSLProcessor->transform();
      if(vtRet != VARIANT_TRUE)
      {
         MessageBox(NULL, "transformation failed","Error", MB_OK);
         return -1;
      }
      _bstr_t bstrOutput  = pXSLProcessor->Getoutput();


      MessageBox(NULL, bstrOutput,"Transformed Output", MB_OK);

   }
   catch(_com_error &e)
   {
      dump_com_error(e);
   }
   return 0;
}


int checkParseError(IXMLDOMParseErrorPtr pError)
{
   _bstr_t parseError =_bstr_t("At line ")+ _bstr_t(pError->Getline())
+ _bstr_t("\n")+ _bstr_t(pError->Getreason());
   MessageBox(NULL,parseError, "Parse Error",MB_OK);
   return -1;

}

void dump_com_error(_com_error &e)
{
   printf("Error\n");
   printf("\a\tCode = %08lx\n", e.Error());
   printf("\a\tCode meaning = %s", e.ErrorMessage());
   _bstr_t bstrSource(e.Source());
   _bstr_t bstrDescription(e.Description());
   printf("\a\tSource = %s\n", (LPCSTR) bstrSource);
   printf("\a\tDescription = %s\n", (LPCSTR) bstrDescription);
}
Style Sheet: "d:\\inetpub\\wwwroot\\sampleXSLWithParam.xml"

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
   <xsl:output method="html"/>
   <xsl:param name="param1"/>
  <xsl:template match="/">
      The parameter value was: <xsl:value-of select="$param1"/>
  </xsl:template>
</xsl:stylesheet>
Output (in a message box)

<?xml version="1.0" encoding="UTF-16"?>
<bar>
Add Parameter Test
</bar>

0
Gadrin (3)
10/28/2005 5:49:22 AM
Reply:

Similar Artilces:

Query That Pulls Multiple Businesses
Hi, I have a single table that my query is built from: clients_tbl id clientname line_of_business revenue In my query I can pull a single line of business name by using this: Like [Enter Name of LOB] & "*" What I would like is the abililty to pull multiple lines of business in the same query. Thanks, JCrowe ...

How do i create a calendar with M-F as the main days
I am creating a school calendar. I have several things for M-F - nothing on Sat/Sun. I need the space - how do I make S/S the smallest days - just the date actually without making the rest of the days small? Can I move S/S to the lRight of the calendar? How? Resize the columns. I have 2006 and 2007 Monday start calendar on my web site, Saturday and Sunday are on the right. It is a no frill calendar. http://msauer.mvps.org/publisher_projects2.htm -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com http://officebeta.iponet.net/en-us/...

Append Query Not Working 02-15-08
I have an append query that has worked in the past but now when I run it I get the long error message,"Microsoft Access can't append all the records in the append query..." I have checked everything and cannot find the problem. Since I cannot attach the screen shot of the error message, here is the SQL code for the query: INSERT INTO sick_history ( emp_no ) SELECT ee.emp_no FROM ee LEFT JOIN sick_history ON ee.emp_no = sick_history.emp_no WHERE (((sick_history.emp_no) Is Null)); Right now I need to add 80 records to the sick_history table and cannot due to this error. TIA,...

Help with query calculation
I need a calculation to determine holiday pay. I have the total hrs work*5.6/52 is the calcuation I use. HOWEVER if the person works more than 39 hrs a week those hours have to be ignored. So if someone worked say 50hrs how would I do the same calculation but ignoring all hours worked beyond 39? Thanks Craig finally solved it using the IIF function "Craig McLaughlin" <info@NOTHANKS.discoverymedia.co.uk> wrote in message news:OoJQsO28KHA.5476@TK2MSFTNGP06.phx.gbl... >I need a calculation to determine holiday pay. > > I have the total hr...

How to Make Table query create a Yes/No field
I have a query which will make a table which will then be used in a form for some data entry/manipulation. I want to put a couple of Yes/No fields in that table, filled with "no." I can set the property of the field in the design grid to yes/no. The field itself, I have tried: Approved:no Approved:"no" Approved: 0 The first generates an error, The second generates a text field, the third generates a number field. How do I generate a Yes/No field? consider; instead of a MakeTable query use an AppendQuery; you can then premake your table with the field property be...

create email button
Several years ago I received a tip on how to create a button that would email a certain person. It went into the Standard email bar. Unfortunately that .pst went with a hard drive that stopped working one night about two years ago. I think I read it in a daily tip from C-Net/Dummies or something like that. I cannot locate it, nor replicate it. Basically it was like the "New" button, but it was to a specific person. It could be a single button, or have a drop-down for different addresses. If anyone knows what I am referring to, please reply with location of the steps or paste the six...

create chart with significant data in a column
I would like to create a chart in excel with data in a column but only want the significant data used. For example, I have two columns - one with names and the other with values ranging from 0 to 10 (the cell is blank). The colums are long. I want a chart from these columns that only uses the cells that have values in larger than 5. Is there a way to do this without me going through the data and only selecting the appropriate cells? An even better solution would be to reference a different cell for the minimum value to use. thanks Select your data, go to the Data menu, select F...

Pivot table to query data in a set range
I'm with a real estate company and we do a lot of analysis of properties in specific price ranges. Is there a way in a pivot table to set filters by a range of data? For example, I want to look at average days on market for properties that are priced $500K to $1M? You can do with Auto Filter. "adman4" wrote: > I'm with a real estate company and we do a lot of analysis of properties in > specific price ranges. Is there a way in a pivot table to set filters by a > range of data? For example, I want to look at average days on market for > proper...

Create and distribute add-in
Hi there, I have some useful code in my normal template which I would like to convert to an add-in and distribute to colleagues. Users are a mix of Word 2003 and 2007. Any help much appreciated. Libby For general advice, see http://www.word.mvps.org/FAQs/MacrosVBA/DistributeMacros.htm. The act that makes an add-in is to store a template in Word's Startup folder. The default location of that folder is the hidden folder %appdata%\Microsoft\Word\Startup. There are a few differences between Word 2003 and Word 2007 that could cause problems for a macro that needs to ...

Flicker problem while creating and destroying child dialog control....
Hi i am facing a flickering problem while creating and destroying child dialogs on a parent dialog. basically its a dialog based applicationb with child dialogs, those appear & destroy on different buttons click. I am placing dialogs on static control rect area. Child dialog create and destroy well but there is flickering problem. Child Dilogs have the following properties set: Style: Child Border: Dailog Frame More Style: visible, control (tick means enable) Extended Style: transparent (tick) Could anybody please help me out Thanks in advance... Mujtaba Set the WS_CLIPCHILDERE...

SBS2003 + ISA2004 + iPhone query
An accountant friend of mine has an SBS 2003 Premium server with ISA 2004. He also has an iPhone. He has two broadband lines at his home office, one for domestic use and one for his accountancy business use. So he has two separate LAN's, one home and one business...(bear with me) bot fitted up for Wireless connections. His business broadband line is faster and better than his domestic line and he doesn't have to share that with his family. So he tends to connect his iPhone to his SBS 2003 LAN as performance is better. Question. When he wants to watch certai...

Grouping duplicate/nonstandardized names and addresses AND Removing the "First of" label when using the First Of option in queries
Hello: I may be approaching this the wrong way, so feel free to direct me otherwise. I am trying to group a list of duplicative data (names, addresses, etc) that does not have a unique identifier, other than their full name (which in some cases can be more than one person). I am trying to do decent job of reducing the nonstandardized entries to a single entry. To do this, I am first concatenating and grouping by a short name (such as the first four 8 letters of their name, plus their zip code), using the left function. When I run a totals query, I group by the short name, and use a "FI...

Problems with Crosstab Query
This should be so simple, but I'm about to tear my hair out. I have a crosstab query based on a table, left joined to a query which selects distinct FYs from another table, so that all FYs will show as column headings. Pretty standard stuff. The strange thing about this is that the crosstab query returns a single blank record, in addition to the records I expect. But even stranger is that, if I add a WHERE clause to the query, the query no longer returns all the fields from the left-joined FY query, so column headings which have no data are now missing. Details: Using Ac...

WEb Query... help!
Using Office XP I am creating a web query that pulls down a <name>.ttx file from a web page. When I normally browse to the web page in IE and hit the link to this file it only gives me the File Download box with the standard "Open file from it's Current Location" or "Save this File to Disk" options. I go into Excel and do Import External Data from the Data Menu and select New Web Query. I browse to this site and try to get it to import the *.ttx file. When I click on the link for that file it again gives me the "Open file from it's Current Location&qu...

Queries
Is there a way to lock a column width in so that when using a query-based spreadsheet, the column isn't resized each time the sheet is refreshed? I answered my own question. From excel you can modify the data range properties. One checkbox was checked "Adjust column width". Uncheck it and voila, no more column width changes. I happen to be sure my column data won't exceed given widths - a note to any who use this particular fix - if your data is wider than the column and you've specified not to adjust column width, the column will only show partial data. <shrug&...

Publisher 2007 will not open up after hitting CREATE.
I have tried all the previous suggestions: Diagnostics Repair Unistalling Printers Is it possible that it is a "bad" install? Would i need to receive a new set of discs? Please help. Thanks. Can you open a Publisher file by double-clicking it? If you can disable the *Getting Started" menu. Tools, Options, uncheck *Show Publication types when starting Publisher.* -- Mary Sauer http://msauer.mvps.org/ "Kurt P." <KurtP@discussions.microsoft.com> wrote in message news:5112DC5B-F244-44F2-BDD2-4213BFBF6EB5@microsoft.com... >I have tried all the previo...

Creating and using a GUI thread
Hi, I need to update a control 20 times a second (its a graph control). I want to place the control into a separate GUI thread what simply spins and updates the control on my dialog. How can i do this? I have a class that does the updating and data handling etc, but when i write the data to the control, the GUI freezes because its too quick. Does anyone have an example code to update a control (progress bar for example) in a separate thread? Please help! J On Wed, 19 Apr 2006 10:16:32 +0100, JoeB <joe@nospam.com> wrote: >Hi, > >I need to update a control 20 times...

Creating delete query based on matching fields between two tables
I'm sure there's already one if not several posts for this but I couldn't any. I have two tables both the same serial code field. I want to a basic delete from tableA where tableA and tableB have matching serial codes. I have tried just joining the two table by the serial code field in a delete query but no matter how I try to go about it nothing works. Thanks in advance for any assistance you can provide on this issue. DBGuy11 DELETE FROM tableA WHERE tableA.SerialCode IN (SELECT DISTINCT SerialCode FROM tableB) -- Doug Steele, Microsoft Access MVP http://...

How do I print query parameters on the report?
I'll try to keep this short. I have created a query with multiple parameters. I want to print reports showing invoices to a specified customer between certain dates. When I run the query, it is set up to enter the customer name first, and then type the beginning date of the invoice period, and then type the ending date of the invoice period. I have that part down okay. When I print the report, I want the date parameters that I typed in for the query to appear on the printed report. I created a text box in Design View on the report, and for the Control Source, I entered the sam...

Create new Activity Type
hi how can i create a new Activity Type such as "new fax" or ...? Thanks PIT Unfortunately, there is no supported way to do this. The best option is to either "categorize" an existing type by adding a picklist or by re-using one of the 6 types you are not using. -- Matt Parks MVP - Microsoft CRM "PIT" <PIT@newsgroup.nospam> wrote in message news:6A7F437B-9BF1-44E3-98B4-EE60AA0AD9A3@microsoft.com... hi how can i create a new Activity Type such as "new fax" or ...? Thanks PIT Hi Matt, thanks for your post. I am new in crm. can y...

Can Pivot Table views of a query be saved as a favorite?
....if so, how? Yes. Have the query properties sheet visible (right click on an empty spot on the top half, if not, or use the toolbar): the second property is Default View. Specify the one you wish to get. Hoping it may help, Vanderghast, Access MVP <soarathorn@gmail.com> wrote in message news:1177084713.529654.35070@l77g2000hsb.googlegroups.com... > ...if so, how? > ...

Creating forms on the fly?
Hi there, hopefully somebody will be able to offer me some words of advice. I am creating a database for a firm that deals with property insurance claims. Creating a databse of relevant contacts etc ... is not a problem. The current system that the company uses is that of an excel spreadsheet, where the details for each room are recorded and relatively simple calculations are carried out on this. The details needed for each room are the same (ie height, width, damage floor etc ...), the variation being for each claim being how many rooms. My intention is to move the system comp...

how to create new organization business unit
anyone knows how to create new database/business unit. do i need to reinstall the crm server and select new database. >-----Original Message----- >anyone knows how to create new database/business unit. do >i need to reinstall the crm server and select new database. >. > Do you need a new Business Unit, or do you need to change the Organisation name ? ah..new organization name...like abc company...? may i know what is the difference between organization and business unit? >-----Original Message----- > >>-----Original Message----- >>anyone knows how to...

Created 3-panel brochure; how to edit back 3 pages?
Hi, I created a 3-page brochure and edited the content of the three pages. When I printed it, I got two physical sheets: the front three pages and the back three pages. I need to edit the content of the back three pages. How do bring them up for editing? BTW, when I find a duplex printer to produce the fully edited brochure, I'll be in Publisher Heaven :-) Thanks in advance, Richard Hi, again, Never mind; I found it. I opened a practice session and, happily, it started with a brochure. That example pointed out that it started with two pages. That made me take notice of the littl...

create a guid
Hello. How can I in VB. NET 2005, I can auto-generate a GUID number ? Thanks :) Hello, Try : http://msdn.microsoft.com/en-us/library/system.guid.newguid.aspx The object browser can also help to discover available methods, classes, structures etc... -- Patrice "Mr. X." <nospam@nospam_please.com> a �crit dans le message de groupe de discussion : ##GJIjdmKHA.4872@TK2MSFTNGP05.phx.gbl... > Hello. > How can I in VB. NET 2005, I can auto-generate a GUID number ? > > Thanks :) > > I remember once I did that by some key combinati...