|
Could you find the NodeName node in the XML and post what that looks like?
|
|
|
|
|
Here's a little more of the original xsl that is failing. I thought this would be a simple syntax error or something so didn't post the surrounding loop.
Here it is:
<xsl:for-each select="//node[NodeParentNodeIdent = $ThisIdent][PagePublished = 'True']">
<xsl:if test="NodeIdent = //LinkedPageDetail/PageIdent">
<xsl:copy-of select=""/>
<xsl:variable name="reportName" >
<xsl:value-of select="normalize-space(NodeName)"/>
</xsl:variable>
<xsl:value-of select="$reportName"/>
<xsl:value-of select="//PageXML/Document/report[name = $reportName]/regionalFlag"/>
<br />
<!--<xsl:value-of select="//PageXML/Document/report[name = 'workordertime']/regionalFlag"/>-->
<xsl:variable name="regionFlag">
<xsl:value-of select="//PageXML/Document/report1"/>
</xsl:variable>
<p><a href="{PageBreadcrumb}?UseRegions={$regionFlag}" target="_blank"><xsl:value-of select="PageTitle" disable-output-escaping="yes"/></a></p>
</xsl:if>
</xsl:for-each>
And here is the current node of that loop when it should find the workordertime report and print it's value:
<node>
<TreeIdent>2</TreeIdent>
<NodeIdent>274</NodeIdent>
<TreeName>Synergy - ePortal</TreeName>
<NodeName>workordertime</NodeName>
<NodeLevel>3</NodeLevel>
<NodeParentNodeIdent>273</NodeParentNodeIdent>
<SiteIdent>2</SiteIdent>
<SiteSortOrder>1</SiteSortOrder>
<SiteName>Synergy - ePortal</SiteName>
<SiteDescription>Synergy - ePortal</SiteDescription>
<SiteTitle>Web Site - Synergy - ePortal - QuantumCMS</SiteTitle>
<SitePublished>True</SitePublished>
<PageShowInNav>False</PageShowInNav>
<PageBreadcrumb>/Home/Reports/summaries/workordertime</PageBreadcrumb>
<PageIdent>274</PageIdent>
<PageSortOrder>1</PageSortOrder>
<PageName>workordertime</PageName>
<PageDescription>Workorder Time</PageDescription>
<PageTitle>Workorder Time</PageTitle>
<PageLevel>3</PageLevel>
<PageLeftBound>125</PageLeftBound>
<PageRightBound>126</PageRightBound>
<ParentNodeIdent>273</ParentNodeIdent>
<ParentPageIdent>273</ParentPageIdent>
<PageTypeIdent>1</PageTypeIdent>
<PageTypeName>Document</PageTypeName>
<PageSummary></PageSummary>
<PageReleaseDate>2006-10-03T00:00:00.0000000-04:00</PageReleaseDate>
<PageRevision>1</PageRevision>
<PageCached>False</PageCached>
<PageSearched>False</PageSearched>
<PageRequired>False</PageRequired>
<PagePublished>True</PagePublished>
<PageActive>True</PageActive>
<PageURL>/Home/Reports/summaries/workordertime</PageURL>
</node>
It's basically inside of another node just like it, and this for-each loop is an inner loop from another for-each loop.
|
|
|
|
|
Well, I thought maybe NodeName had something strange about it, but that doesn't seem to be the case. The variable looks fine and I recreated very similar XML and XSL files and it worked without a problem. There are two things I can think of to try. First, declare your variable like this:
<xsl:variable name="reportName" select="NodeName"/>
But I doubt that will have an effect. The other thing is to comment out that if statement in the loop. It may be correct, but it looks like a really odd syntax. NodeIdent = //LinkedPageDetail/PageIdent looks to me like you're comparing the contents of NodeIdent to a list of nodes PageIdent anywhere in the document. It may be putting you in a different position in the XML document unexpectedly.
Just grasping at straws really.
|
|
|
|
|
Actually, <xsl:variable name="reportName" select="NodeName"/> worked!
Thanks for your help!
|
|
|
|
|
[ This has been answered ]
My path is to ( my conditional )
/Events/CompanyABC/Transaction/ProductList/Product/Event/Code = 435
The actual node I want:
/Events/CompanyABC/Transaction/ProductList/Product/LoanList/Loan/ReturnedType
I tried this:
//Events/CompanyABC/Transaction/ProductList/Product[./Event/Code = '435']/LoanList/Loan/ReturnedType
But it doesn't return anything.
How can I combine the conditional into the xpath statement. This has to be one string, I can't split it.
Thanks,
Nick
-- modified at 13:04 Tuesday 24th October, 2006
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Ista wrote: /Events/CompanyABC/Transaction/ProductList/Product/Event/Code = 435
Is Code an attribute or an element? If it's an attribute, prefix it with @ in the query to indicate that it's an attribute name.
|
|
|
|
|
lol. Nah thier all elements.
And actually it worked. I just had the wrong events.
Thanks for helping tho
--------------------------------------------------------
1 line of code equals many bugs. So don't write any!!
My mad coder blog
|
|
|
|
|
Given the following XSD File
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Item">
<xs:complexType mixed="true">
<xs:attribute name="uri" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="Collection">
<xs:complexType>
<xs:sequence>
<xs:element ref="Item" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="Structure">
<xs:complexType>
<xs:sequence>
<xs:annotation>
<xs:documentation>Sequence</xs:documentation>
</xs:annotation>
<xs:choice>
<xs:annotation>
<xs:documentation>Choice Element</xs:documentation>
</xs:annotation>
<xs:element ref="Item">
<xs:annotation>
<xs:documentation>Singular Item (Doesn't have to be a reference)</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element ref="Collection">
<xs:annotation>
<xs:documentation>Collection of Items (Must be a Reference)</xs:documentation>
</xs:annotation>
</xs:element>
</xs:choice>
<xs:element name="Count" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
As you can see there is a **choice element ** which has a choice of either a singular Item or a collection of Items. When you use XSD.exe to create the classes in .net you get the following:
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Collection", typeof(Item[]))]
[System.Xml.Serialization.XmlElementAttribute("Item", typeof(Item))]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
So .NET xsd.exe recognises it’s a choice element and creates the Serialization correctly.
The problem occurs when you try and create a “WebReference” to the web service in a client application. If you look at the reference.cs it has an incorrect version:
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Collection", typeof(ArrayOfItemItem[]))]
[System.Xml.Serialization.XmlElementAttribute("Item", typeof(TestXSDResultItem))]
public object Item {
get {
return this.itemField;
}
set {
this.itemField = value;
}
}
As a result if you try and consume the web service by setting the choice element to a collection and returning that through the WS back into the client application you’ll end up with an empty collection always.
Can anyone help. I've a more detailed explanation and an example application if you want to email me and get that?
All Comments appreciated.
Dave
|
|
|
|
|
I'm not sure off hand from your description if this will help or not, but I have a tool that builds code from XSD, but in the case of a Choice, I generate a property for each choice on the class. The code generated is XML serializable. You might want to grab a copy of the trial and see if it does what you need.
You can try it on-line here[^], or you can download the trial here[^]
Hope that helps.
|
|
|
|
|
Got a fix from Microsoft in the end. Horah!
FIX: A deserialized object may contain null objects when you deserialize an object from XML in the .NET Framework 2.0
http://support.microsoft.com/kb/918298
|
|
|
|
|
Hi All,
If we have a table in database which has one of the columns as XMl, we can use that XML record.value('/fieldname[1]','varchar(10)') to get the actual value of the fieldname from that XML record.
But what if we don't know the exaxt name of the field whose value has to be fetched, but we are sure that the pattern we give in will only fetch us one record, then is there a way to specify a pattern matching stuff like a normal like statement using '%Something', which would give us all records ending in "Something".
How do i do this.
Pls guide me
Omkar
|
|
|
|
|
you can try it, you want to get data form the table in xml format.
"Select * from table_name FOR XML AUTO"
this Query will returning the data in xml format.
Select * from table_name FOR XML EXPLICIT
this Query specify the "shape" of the XML data.
Select * from table_name FOR XML ELEMENTS
Enjoy
Pavan Pareta
|
|
|
|
|
hi,
i want to stroe image in xml file without using image file path, image file should be only and only in xml file. please help me.
-- modified at 1:11 Friday 20th October, 2006
Pavan Pareta
|
|
|
|
|
|
Check the NodeType to avoid endelement tags:
while(objXmlTextReader.Read())
{
if (objXmlTextReader.NodeType != XmlNodeType.EndElement)
Databasecb.Items.Add(objXmlTextReader.Name.ToString());
}
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
thanks stefan
ur help was greatly valued and appreciated.
until next time
goodbye
|
|
|
|
|
hello friends
i'm trying to insert new tags into an already existing XML document.
but it is not working properly. i get the exception
"The writer is closed"
the code i'm using is:
<br />
doc.Load(Application.StartupPath + @"\Databases.xml");<br />
<br />
XmlElement newElement=doc.CreateElement(Global.Instance.DBname); <br />
doc.DocumentElement.AppendChild(newElement);<br />
dbTextFile.Formatting=Formatting.Indented;<br />
<br />
doc.WriteContentTo(dbTextFile);<big><---EXCEPTION GENERATES HERE</big><br />
<br />
dbTextFile.Close();<br />
MessageBox.Show("The following file has been successfully upgraded\r\n"+ sStartupPath+ @"\Databases.xml", "XML", MessageBoxButtons.OK,MessageBoxIcon.Information);
|
|
|
|
|
Where do you create the XmltextWriter passed to the WriteContentTo method? I seems you already called Close on this writer and need to create a new one.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
heres another problem. i'm getting another exception that states that::
"the process cannot access the .....\Databases.xml" because it is being used by another process."
i've checked the process that are running but can't seem to find it.
the exception arises whenever i use the code
doc.Load(Application.StartupPath + @"\Databases.xml");
can u please tell me what the problem is??
thanks
-- modified at 4:36 Wednesday 18th October, 2006
|
|
|
|
|
Obviously something exclusively accesses the XML file. Maybe the XmlTextWriter that I saw in the code of your starting post. Hard to say without knowing the code.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi all,
We have an xsl file from which we are reading content and displaying it in a .aspx page.
We want to include a footer at the end of every page in the print preview.
We are facing a lot of problems in the positioning of the footer.
Is there any way to ensure that the footer comes at the end of the page irrespective of the page content ala footer in word?
Thanks in anticipation.
If you fail for the first time , call it version 1.0.
|
|
|
|
|
Hi,
I am trying to use XML file as an config file. The structure of the xml file is quite simple. It needs to have only
5 fields. This file stores information about 3 websites - so ideally structure should be like
<root>
<config>
<website 1="">
<url>test
<delay>23
<username>23
<password>32423
<website 2="">
<url>test
<delay>23
<username>23
<password>32423
I am using following code to create this Xml schema and xml file - but having some trouble (which i don't know WHY -
and I seek your guidence...)
public void create_Config_Table(string service_name, string url, string delay,
string freq, string username, string password)
{
string filename = "config.xml";
FileStream fs;
XmlTextWriter xtw;
XmlTextReader xtr;
string msg = "";
//create the table and then populate it
DataTable ret = new DataTable(service_name);
//Create the DataSet
DataSet ds = new DataSet("AutoMessage");
//first check if config.xml exists or not
//If it already exists then we don't have to recreate the XML schema for it
if( ! File.Exists(filename) )
{
//ret.Columns.Add("Service", Type.GetType("System.String"));
ret.Columns.Add("URL",Type.GetType("System.String"));
ret.Columns.Add("Delay", Type.GetType("System.String"));
ret.Columns.Add("Frequency",Type.GetType("System.String"));
ret.Columns.Add("Username",Type.GetType("System.String"));
ret.Columns.Add("Password",Type.GetType("System.String"));
//Now populate the data table
DataRow row = ret.NewRow();
//row["Service"] = service_name;
row["URL"] = url;
row["Delay"] = delay;
row["Frequency"] = freq;
row["Username"] = username;
row["Password"] = password;
ret.Rows.Add(row);
ds.Tables.Add(ret);
msg = "Config File Created";
}
else
{
//Read the XML File
try
{
fs = new FileStream(filename, FileMode.Open);
xtr = new XmlTextReader(fs);
ds.ReadXml(xtr);
xtr.Close();
DataTable dt = ds.Tables[0];
DataRow row = dt.NewRow();
//row["Service"] = service_name;
row["URL"] = url;
row["Delay"] = delay;
row["Frequency"] = freq;
row["Username"] = username;
row["Password"] = password;
dt.Rows.Add(row);
ds.Tables.Remove(ds.Tables[0].TableName);
ds.Tables.Add(dt);
msg = "Config File Updated";
}
catch(Exception ex) { Console.Error.WriteLine(ex.ToString() ) ; }
fs = null;
}
try
{
fs= new FileStream(filename, FileMode.Append,FileAccess.Write);
xtw = new XmlTextWriter(fs, System.Text.Encoding.Unicode);
ds.WriteXml(xtw);
xtw.Close();
Console.Write(msg);
}
catch(Exception ex) { Console.Error.WriteLine(ex.ToString() ); }
}
Logic here is that if file doesn't exists - it will create the xml schema and the xml file
if it does EXISTS - then it is read into an dataset - new values are appeneded to contents of this dataset it is
written back as a xml file.
- Major problem is that it creates a mal-formed XML (multiple root elements)
-- Any Suggestions
THanx in advance
|
|
|
|
|
System.IO.StringReader sr = new System.IO.StringReader(ds.GetXml());
System.Xml.XmlTextReader xtr = new System.Xml.XmlTextReader(sr);
ds.WriteXml("cpTest.xml");
Creates a file which looks like the following;
<AutoMessage>
<Services>
<URL>test.com</URL>
<Delay>5</Delay>
<Frequency>10</Frequency>
<Username>mnvkng76</Username>
<Password>aPassword</Password>
</Services>
</AutoMessage>
Is that what you needed?
|
|
|
|
|
This is what I want:
ns0:Interchange xmlns:ns0="http://www.e2b.no/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.e2b.no/XMLSchema e2b_Invoice_Interchange_v3p2.xsd"
The attribute schemaLocation I make with this code
<br />
XmlAttribute atrXsiSchemaLocation = null;<br />
atrXsiSchemaLocation = invoiceE2BDocument.CreateAttribute("xsi:schemaLocation");<br />
atrXsiSchemaLocation.Value = "http://www.e2b.no/XMLSchema e2b_Invoice_Interchange_v3p2.xsd";<br />
elmInterchange.Attributes.Append(atrXsiSchemaLocation);<br />
But the "xsi:" is somehow gone and I get
schemaLocation="http://www.e2b.no/XMLSchema e2b_Invoice_Interchange_v3p2.xsd"
So I replaced the code with:
<br />
atrXsiSchemaLocation = invoiceE2BDocument.CreateAttribute("xsi", "schemaLocation", "xsi");<br />
but then I got:
d3p1:schemaLocation="http://www.e2b.no/XMLSchema e2b_Invoice_Interchange_v3p2.xsd" xmlns:d3p1="xsi"
Does anyone know how to fix this?
Thanks
Thomas
-- modified at 8:35 Friday 13th October, 2006
|
|
|
|
|
Does the following work?
atrXsiSchemaLocation = invoiceE2BDocument.CreateAttribute("xsi", "schemaLocation", "http://www.w3.org/2001/XMLSchema-instance");
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|