Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all 935 articles
Browse latest View live

Large XML file break up

$
0
0

Hi,

 I want to write data to a xml file by breaking it into two sections. One section will be xml data and other section will be in the form of binary data so as to minimize file size. What could be the best approach for this. Still I should get xml file validated against my xsd file.

Thanks


Exception during msxml6 FreeObjects

$
0
0
Hi,

I have a relatively complicated test written in VB.NET.  This test invokes COM objects through interops.  Those COM objects intern invoke functionality in the MSXML6.dll.  My test finishes successfully and I see the last print statements I've made in the test.  After the test has finished it appears kernel32 is invoking ExitProcess.  At that time i get a pop up window that states 
"The

instruction at "0x58830fa1" referenced memory at "0x00000038". The memory could not be

"read""

I was able to get a dump file using windbg.  The stack looks like this:
0012f464 7c827779 77e827d0 d0000144 00000004 ntdll!KiFastSystemCallRet
0012f468 77e827d0 d0000144 00000004 00000000 ntdll!ZwRaiseHardError+0xc
0012f6d4 77e76a20 0012f6fc 77e61ac1 0012f704 kernel32!UnhandledExceptionFilter+0x51a
0012f6dc 77e61ac1 0012f704 00000000 0012f704 kernel32!BaseProcessStart+0x39
0012f704 7c828772 0012f7e8 0012ffe0 0012f804 kernel32!_except_handler3+0x61
0012f728 7c828743 0012f7e8 0012ffe0 0012f804 ntdll!ExecuteHandler2+0x26
0012f7d0 7c82857e 000b5000 0012f804 0012f7e8 ntdll!ExecuteHandler+0x24
0012f7d0 58830fa1 000b5000 0012f804 0012f7e8 ntdll!KiUserExceptionDispatcher+0xe
0012fb04 5885fd3b 04b1d758 04b03780 00000000 msxml6!Base::FreeObjects+0x8f
0012fb24 5885f710 54ab668e 00000000 00000001 msxml6!Base::FinishFreeObjects+0x7c
0012fb54 58870ec1 0012fb74 0012fb80 7c81a352 msxml6!Runtime_exit+0xbc
0012fb60 7c81a352 58800000 00000000 00000001 msxml6!InitDllMain+0xdd
0012fb80 7c830e90 5885ab78 58800000 00000000 ntdll!LdrpCallInitRoutine+0x14
0012fc38 77e668ab 00000001 79fdc3f8 00000000 ntdll!LdrShutdownProcess+0x182
0012fd24 77e6690d 00000000 77e8f3b0 ffffffff kernel32!_ExitProcess+0x43
0012fd38 79fdc3d4 00000000 00000000 00000000 kernel32!ExitProcess+0x14
0012ff60 79f082a8 00000000 01000000 79f07e56 mscorwks!SafeExitProcess+0x157
0012ffb0 79007c24 00000000 79e70000 0012fff0 mscorwks!DisableRuntime+0xdc
0012ffc0 77e6f23b 00000000 00000000 7ffdf000 mscoree!_CorExeMain+0x2c
0012fff0 00000000 79007bf0 00000000 78746341 kernel32!BaseProcessStart+0x23

Has anyone seen a similar issue?  Of course I googled (oops i mean binged :) ) and couldn't seem to ask the correct question, or no one has experienced what I am.

I am running my test on a 2003 SP2 VM.

Smart pointers are being used and the create call that is being may is:

#import "msxml6.dll" rename_namespace("ExMSXML")
ExMSXML::IXMLDOMDocument2Ptrm_XMLDocument;
m_XMLDocument.CreateInstance(_T("Msxml2.FreeThreadedDOMDocument.6.0"));

Thanks in advance for any help you all can provide.

-Justin

XSD generated code with string restrictions

$
0
0

Hello all,

In my application, i am generating .cs code file using XSD.exe tool. I have added few restrictions in my XSD for string data types. These restrictions are nothing but the length of the string element present in the XML file.

How i can get these restrictions in my XSD generated classes as an attribute or any other way? Here is the XSD restriction for which i want some information in the XSD tool generated classes.

<xs:simpleType name="AsciiText_20_FixedLength_Type"><xs:restriction base="xs:string"><xs:maxLength value="20" /></xs:restriction></xs:simpleType>

Thanks in advance,

IamHUM

how to deserialize xml with structure of abitrary nested layers of base class?

$
0
0

let say i want to represent arithmetic expression using xml:

<?xml version="1.0" encoding="utf-8" ?><expr><add><num>10</num><num>20</num></add></expr>

and here is my classes to represent this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test
{
    public abstract class Evaluable
    {
        public abstract int Eval();
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Test
{
    [Serializable]
    [XmlRoot("expr")]
    public class Expr
    {
        [XmlElement]
        public Evaluable Evaluable { get; set; }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Test
{
    [Serializable]
    [XmlRoot("add")]
    [XmlType("add")]
    public class Add : Evaluable
    {
        [XmlElement]
        public List<Evaluable> Elems { get; set; }

        public override int Eval()
        {
            return Elems.Select(e => e.Eval()).Sum();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Test
{
    [Serializable]
    [XmlRoot("num")]
    [XmlType("num")]
    public class Num : Evaluable
    {
        [XmlText]
        public int Val { get; set; }

        public override int Eval()
        {
            return Val;
        }
    }
}

but it doesn't work, and it's reasonable, since Serializer doesn't know any thing about the subclass. but how to make it work?

here is my deserialization code:

var serializer = new XmlSerializer(typeof(Expr), new[] { typeof(Add), typeof(Num) });
            Expr expr = null;
            using (var file = new StreamReader("expr.xml"))
            {
                expr = serializer.Deserialize(file) as Expr;
            }

XML-DSIG URI digest calculation?

$
0
0

I am analyzing an XML-DSIG file in order to know how to write my piece of software code that generates XML-DSIGnatures. I am having this trouble and desperately need help...
I am trying to understand this bit from signatures0.xml (quoted after this bit):

<Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedPropertiesElem_0" xmlns="http://www.w3.org/2000/09/xmldsig#"><Transforms xmlns="http://www.w3.org/2000/09/xmldsig#"><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>kOlNXyBs6oSP9hbh+4niZMNQ9OsOCzYhkSYYG4YdHQU=</DigestValue></Reference>

from signatures0.xml:

<?xml version="1.0" encoding="UTF-8"?><document-signatures xmlns="urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0"><Signature Id="SignatureElem_0" xmlns="http://www.w3.org/2000/09/xmldsig#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><SignedInfo><CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/><SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/><Reference URI="metadata/signableMetadata0.xml" xmlns="http://www.w3.org/2000/09/xmldsig#"><Transforms xmlns="http://www.w3.org/2000/09/xmldsig#"><Transform Algorithm="http://www.w3.org/TR/1999/REC-xpath-19991116"><XPath>ancestor-or-self::*[@ID='signature_0']</XPath></Transform><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>XIrOvoOM33rWvV5Fdckax/bNLOpR9RNIonkVQ22fczM=</DigestValue></Reference><Reference URI="1.docx" xmlns="http://www.w3.org/2000/09/xmldsig#"><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>LtTwOA0L3mL4mswjGL3JwkumufovE/A75M4MGSUm6PQ=</DigestValue></Reference><Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedPropertiesElem_0" xmlns="http://www.w3.org/2000/09/xmldsig#"><Transforms xmlns="http://www.w3.org/2000/09/xmldsig#"><Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/></Transforms><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><DigestValue>kOlNXyBs6oSP9hbh+4niZMNQ9OsOCzYhkSYYG4YdHQU=</DigestValue></Reference></SignedInfo><SignatureValue>
EPuWjb6IeuYg32FT1tInmO7FPL1ISuluFvrPqzHdHyJ0ymgMFitaWPJQk0MV6ckgmvFwif6zpg5C
XLVJl4U+e/+AmS1AkwMf2TmnuIONuB8oLeYcDUCr+0xxlwgKSZoopzapD7ylZxIwCPTMr6BT3lx9
8EFHHVskC4wVihR0JsJWBl2YzGnBevCWpknGofa8t8vOHpTA2y9VSAu5ETXnKYF5Ms04kTy5NQ7G
kHcslw+HSAuaJolvfUd4EeqAXVF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cG9zaXRvcnkwHQYJKwYBBAGCNxUKBBAwDjAMBgorBgEEAYI3CgMM
MCIGCCsGAQUFBwEDBBYwFDAIBgYEAI5GAQEwCAYGBACORgEEMA0GCSqGSIb3DQEBBQUAA4IBAQAf
PXZj6QagEgswUy+wit1MdCPMbKnF5LYszPtLG/PYbtuqXstBZljRR1tZVo8DRzoVRKwM7gpNNnWF
UEtZoaafJ4uWmWWZLNSVAyaZUAJ67s2rkDPTtNtb7W9QCZJNIU2klegoY3JvDqAQzheE+Mj9HXnh
0h21Qb8MWq4lHaL99/Vk9OXSlR9WYQfbEB5zbI5kp6nVePM2cf9uOZbhZRLdDAKbL/NrSGca3S40
WZevQ1m9sdMgmobSTyuqniDXYIa7sO+QOzbMPIFuTn/izO13IK63uUBFnTImW+99PAyDx3s4Y03t
EWpXA25hWn/NXH5xWC7ohKKeXzVUhnMN4WxT</X509Certificate></X509Data></KeyInfo><Object><QualifyingProperties Target="#SignatureElem_0" xmlns="http://uri.etsi.org/01903/v1.3.2#"><SignedProperties Id="SignedPropertiesElem_0"><SignedSignatureProperties><SigningTime>2014-08-21T06:09:55Z</SigningTime><SigningCertificate><Cert><CertDigest><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" xmlns="http://www.w3.org/2000/09/xmldsig#"/><DigestValue xmlns="http://www.w3.org/2000/09/xmldsig#">JQ0kZvd0mtXQPA/RTuYV9iuc346tznvN9MoAd/0jNyM=</DigestValue></CertDigest><IssuerSerial><X509IssuerName xmlns="http://www.w3.org/2000/09/xmldsig#">CN=Nacionalinis sertifikavimo centras (IssuingCA-B),OU=Nacionalinis sertifikavimo centras (NSC),O=Gyventoju registro tarnyba prie LR VRM - i.k. 188756767,C=LT</X509IssuerName><X509SerialNumber xmlns="http://www.w3.org/2000/09/xmldsig#">1315010063538360283821765366094690</X509SerialNumber></IssuerSerial></Cert></SigningCertificate><SignaturePolicyIdentifier><SignaturePolicyImplied/></SignaturePolicyIdentifier></SignedSignatureProperties></SignedProperties></QualifyingProperties></Object></Signature></document-signatures>

From what I understand, the first quoted bit refers to a SignedPropertiesElem_0 element in the same file. I am trying to determine exactly what it refers to - what piece of code exactly should be selected and used later on for canonicalization and then calculating a digest value. Is it this:

<SignedProperties Id="SignedPropertiesElem_0"><SignedSignatureProperties><SigningTime>2014-08-21T06:09:55Z</SigningTime><SigningCertificate><Cert><CertDigest><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" xmlns="http://www.w3.org/2000/09/xmldsig#"/><DigestValue xmlns="http://www.w3.org/2000/09/xmldsig#">JQ0kZvd0mtXQPA/RTuYV9iuc346tznvN9MoAd/0jNyM=</DigestValue></CertDigest><IssuerSerial><X509IssuerName xmlns="http://www.w3.org/2000/09/xmldsig#">CN=Nacionalinis sertifikavimo centras (IssuingCA-B),OU=Nacionalinis sertifikavimo centras (NSC),O=Gyventoju registro tarnyba prie LR VRM - i.k. 188756767,C=LT</X509IssuerName><X509SerialNumber xmlns="http://www.w3.org/2000/09/xmldsig#">1315010063538360283821765366094690</X509SerialNumber></IssuerSerial></Cert></SigningCertificate><SignaturePolicyIdentifier><SignaturePolicyImplied/></SignaturePolicyIdentifier></SignedSignatureProperties></SignedProperties>

Or this:

<SignedSignatureProperties><SigningTime>2014-08-21T06:09:55Z</SigningTime><SigningCertificate><Cert><CertDigest><DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256" xmlns="http://www.w3.org/2000/09/xmldsig#"/><DigestValue xmlns="http://www.w3.org/2000/09/xmldsig#">JQ0kZvd0mtXQPA/RTuYV9iuc346tznvN9MoAd/0jNyM=</DigestValue></CertDigest><IssuerSerial><X509IssuerName xmlns="http://www.w3.org/2000/09/xmldsig#">CN=Nacionalinis sertifikavimo centras (IssuingCA-B),OU=Nacionalinis sertifikavimo centras (NSC),O=Gyventoju registro tarnyba prie LR VRM - i.k. 188756767,C=LT</X509IssuerName><X509SerialNumber xmlns="http://www.w3.org/2000/09/xmldsig#">1315010063538360283821765366094690</X509SerialNumber></IssuerSerial></Cert></SigningCertificate><SignaturePolicyIdentifier><SignaturePolicyImplied/></SignaturePolicyIdentifier></SignedSignatureProperties>

Or some other part of it?

I tried the first one, then letting it through a StylusStudio canonicalization OR soapclient.com canonicalizer (both seem to return identical results), which results in this:

<SignedProperties Id="SignedPropertiesElem_0"><SignedSignatureProperties><SigningTime>2014-08-21T06:09:55Z</SigningTime><SigningCertificate><Cert><CertDigest><DigestMethod xmlns="http://www.w3.org/2000/09/xmldsig#" Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"></DigestMethod><DigestValue xmlns="http://www.w3.org/2000/09/xmldsig#">JQ0kZvd0mtXQPA/RTuYV9iuc346tznvN9MoAd/0jNyM=</DigestValue></CertDigest><IssuerSerial><X509IssuerName xmlns="http://www.w3.org/2000/09/xmldsig#">CN=Nacionalinis sertifikavimo centras (IssuingCA-B),OU=Nacionalinis sertifikavimo centras (NSC),O=Gyventoju registro tarnyba prie LR VRM - i.k. 188756767,C=LT</X509IssuerName><X509SerialNumber xmlns="http://www.w3.org/2000/09/xmldsig#">1315010063538360283821765366094690</X509SerialNumber></IssuerSerial></Cert></SigningCertificate><SignaturePolicyIdentifier><SignaturePolicyImplied></SignaturePolicyImplied></SignaturePolicyIdentifier></SignedSignatureProperties></SignedProperties>

and then calculating the digest value using online hash calculation tools. They all returned the same result, but that result is different from the one in the xml file:kOlNXyBs6oSP9hbh+4niZMNQ9OsOCzYhkSYYG4YdHQU=

What am I doing wrong? What part of the xml document should I copy and paste into the canonicalizer and then into digest calculator? I've spent several days trying different things and looking for answers and haven't got anything... I am sure I missed something, therefore I am asking for your help.

error when implementing "IXMLDOMNode" from MSXML2

$
0
0

Dear all,

in VBA I've been creating a new class implementing "IXMLDOMNode" from MSXML2. The result of genarating the Property "get" and "let" functions für "dataType" is the following:

Private Property Let IXMLDOMNode_dataType(ByVal RHS As String)

End Property

Private Property Get IXMLDOMNode_dataType() As Variant

End Property

As shown, the type is not the same for both: "variant" respectively "string". At the end "variant" is correct, I've checked in objectcatalog.  This code cannot be compiled of course and changing "string" to "variant" leads to another error: "The type is not the same as in a function with the same Name".

I currently don't see a solution, any suggestions?

Jürgen

 

Unable to traverse back in xslt

$
0
0

Hi,

I have an issue; I know that we cannot traverse back in xslt. The problem is.

I have the sample xml like this.

<SalesInvoices>
 <Invoice>
  <NumberOfEntries>1367</NumberOfEntries>
  <InvoiceNo>232</InvoiceNo>
  <InvoiceStatus>N</InvoiceStatus>
  <InvoiceStatusDate>2013-07-01 14:56:40</InvoiceStatusDate>
  <Line>
   <LineNumber>10</LineNumber>
   <OrderDate>2013-07-01</OrderDate>
   <ProductCode>10000000083320</ProductCode>
   <ProductDescription>TYVERB 250MG X 140 COMP (FRASCO)</ProductDescription>
  </Line>
  <Line>
   <LineNumber>11</LineNumber>
   <OrderDate>2013-07-01</OrderDate>
   <ProductCode>10000000033444</ProductCode>
   <ProductDescription>Dolo 200mg</ProductDescription>
  </Line>
  <Quantity>2</Quantity>
  <Description>TYVERB 250MG</Description>
  <WitholdingTax>20</WitholdingTax>
 </Invoice>
 <Invoice>
  <NumberOfEntries>1443</NumberOfEntries>
  <InvoiceNo>345</InvoiceNo>
  <InvoiceStatus>A</InvoiceStatus>
  <InvoiceStatusDate>2013-08-22 10:22:40</InvoiceStatusDate>
  <Line>
   <LineNumber>3</LineNumber>
   <OrderDate>2013-08-22</OrderDate>
   <ProductCode>10000000056756</ProductCode>
   <ProductDescription>AUGMENTIN 875/125MGX16 COM</ProductDescription>
  </Line>
  <Line>
   <LineNumber>4</LineNumber>
   <OrderDate>2013-08-22</OrderDate>
   <ProductCode>10000000056443</ProductCode>
   <ProductDescription>AUENDSIN 20 ml</ProductDescription>
  </Line>
  <Quantity>4</Quantity>
  <Description>CARTIA 2.0</Description>
  <WitholdingTax>15</WitholdingTax>
 </Invoice>
</SalesInvoices>

In this, for each invoice parent element there are 2 child Line element sets; this scenario repeats for each invoice set of elements. I get the raw data in xml like -

<XmlContent><SalesInvoices2><NewDataSet>
  <Table>
    <F1>Id#</F1>
    <F2>NumberOfEntries</F2>
    <F3>InvoiceNo</F3>
    <F4>InvoiceStatus</F4>
    <F5>InvoiceStatusDate</F5>
    <F6>LineNumber</F6>
    <F7>OrderDate</F7>
    <F8>ProductCode</F8>
    <F9>ProductDescription</F9>
    <F10>Quantity</F10>
    <F11>Description</F11>
    <F12>WitholdingTax</F12>
  </Table>
 <Table>
    <F1>1</F1>
    <F2>1367</F2>
    <F3>232</F3>
    <F4>N</F4>
    <F5>2013-07-01 14:56:40</F5>
    <F6>10</F6>
    <F7>2013-07-01</F7>
    <F8>10000000083320</F8>
    <F9>TYVERB 250MG X 140 COMP (FRASCO)</F9>
    <F10>2</F10>
    <F11>TYVERB 250MG</F11>
    <F12>20</F12>
  </Table>
<Table>
    <F1>2</F1>
    <F2>1367</F2>
    <F3>232</F3>
    <F4>N</F4>
    <F5>2013-07-01 14:56:40</F5>
    <F6>11</F6>
    <F7>2013-07-01</F7>
    <F8>10000000033444</F8>
    <F9>Dolo 200mg</F9>
    <F10>2</F10>
    <F11>TYVERB 250MG</F11>
    <F12>20</F12>
  </Table>
<Table>
    <F1>3</F1>
    <F2>1443</F2>
    <F3>345</F3>
    <F4>A</F4>
    <F5>2013-08-22 10:22:40</F5>
    <F6>3</F6>
    <F7>2013-08-22</F7>
    <F8>10000000056756</F8>
    <F9>AUGMENTIN 875/125MGX16 COM</F9>
    <F10>4</F10>
    <F11>CARTIA 2.0</F11>
    <F12>15</F12>
  </Table>
 <Table>
    <F1>4</F1>
    <F2>1443</F2>
    <F3>345</F3>
    <F4>A</F4>
    <F5>2013-08-22 10:22:40</F5>
    <F6>4</F6>
    <F7>2013-08-22</F7>
    <F8>10000000056443</F8>
    <F9>AUENDSIN 20 ml</F9>
    <F10>4</F10>
    <F11>CARTIA 2.0</F11>
    <F12>15</F12>
  </Table>
</NewDataSet></SalesInvoices2></XmlContent>

I need to convert the above XML to the format that I had mentioned in the sample; where within each Invoice the Line set of elements repeats. I am not able to arrive at a logic in the xslt; could you please let me know if this is possible.

I tried the following in the XSLT; but I am not able to create 2 sub child set of Line elements for each Invoice; this creates one set of Invoice for each record; I am not sure if I can arrive at the expected logic as per the sample xml in the xslt. This a very critical situation for me, any advice on this will be of much help. Thanks. 

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
    xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"
>
  <xsl:output method="xml" indent="yes"/>

  <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
  <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />


  <xsl:template match="/">
    <Return>
      <xsl:apply-templates select="XmlContent/SalesInvoices2/NewDataSet"/>
    </Return>
  </xsl:template>

  <xsl:template match="Table">  
    <SalesInvoices>  
        <NumberOfEntries>
          <xsl:value-of select="F2"/>
        </NumberOfEntries>
        <InvoiceNo>
          <xsl:value-of select="F3"/>
        </InvoiceNo>
        <InvoiceStatus>
          <xsl:value-of select="F4"/>
        </InvoiceStatus>      
        <InvoiceStatusDate>
          <xsl:value-of select="F5"/>
        </InvoiceStatusDate>
        <LineNumber>
          <xsl:value-of select="F6"/>
        </LineNumber>
        <OrderDate>
          <xsl:value-of select="F7"/>
        </OrderDate>
        <ProductCode>
          <xsl:value-of select="F8"/>
        </ProductCode>
        <ProductDescription>
          <xsl:value-of select="F9"/>
        </ProductDescription>
        <Quantity>
          <xsl:value-of select="F10"/>
        </Quantity>
      <Description>
          <xsl:value-of select="F11"/>
        </Description>
        <WitholdingTax>
          <xsl:value-of select="F12"/>
        </WitholdingTax>
      </SalesInvoices>   
  </xsl:template>

</xsl:stylesheet>


Rpaul

Removing node from xml file?

$
0
0

When a user clicks a "Check Out" button, their name is supposed to be removed from an xml file, and subsequently removed from a list box, indicating they left a meeting. However,I have encountered Null Reference Exceptions during debugging because _xmlNode is null. From my research on this issue, it seems the problem lies in the declaration of XmlDocument and the passing of its instance _xmlDocument to deleteAttendee(). However, I believe that I declared _xmlDocument correctly, and am having difficulty finding where my strategy went off track. I would appreciate any pointers that could help steer me back in the right direction. Thanks!

protected void checkOutButton_Click(object sender, EventArgs e)
        {
            string fileName = Server.MapPath("~/App_Data/attendees.xml");
            XmlTextReader _xmlTextReader = new XmlTextReader(fileName);
            XmlDocument _xmlDocument = new XmlDocument();
            _xmlDocument.Load(_xmlTextReader);
            _xmlTextReader.Close();

            deleteAttendee(inMeetingListBox.SelectedItem.Text, fileName, _xmlDocument);
            inMeetingListBox.Items.Remove(inMeetingListBox.SelectedItem);


        }
static void deleteAttendee(string attendeeName, string fileName, XmlDocument xmlDoc)
        {
            string test = xmlDoc.DocumentElement.ToString();
            XmlElement _xmlElement = xmlDoc.DocumentElement;
            XmlNode _xmlNode = _xmlElement.SelectSingleNode("attendee[@name='asp']");
            _xmlElement.RemoveChild(_xmlNode);
            xmlDoc.Save(fileName);
        }



MSXML2.ServerXMLHTTP problem, moved from server 2003/IIS6 to 2008/IIS7, simple xml between ASP pages broken

$
0
0

Final update>>>

Update: I moved the target to the production server/URL and it works fine(calling from new server, target on production).  So I reversed(calling from production server and target on new server) and it works too.  So it would appear that there is an issue with an ASP script using MSXML2.ServerXMLHTTP to comm with another ASP script on the same server, atleast in server 2008/IIS7.  Works fine with Server 2003/IIS6.  Strange step backwards it would seem to me, oh well.  Perhaps this post here will help someone else.

 

First update>>>

Well, done some more and just read this:

...calls to ServerXMLHTTP must not send requests


to the same virtual server on which the calling script is executing,


correct? IOW, the script http://www.myserver.com/xmlhttpcaller.asp must not


reference any other ASP script on www.myserver.com when calling XMLHTTP.


Doing so can deadlock the script engine.





Even calling an XML source on a different virtual but same physical server


can cause issues, depending on app pools, isolation settings, threading


models of COM objects being used, etc. ...

 

If this is accurate it would seem that this may be the underlying issue with the problem I am having.  If so, I find it curious it has never been a problem on the current production server but if so I will make appropriate changes.  Anyone comment specifically on this info above?

 

original post>>>

I've read hours online about this but have very little to show for it.  Basic gist of what's happening:  ASP page trying to XML to another ASP page in the same dir.  Following code sits for 30 seconds and times out.  It actually gets to the target page at the *end* of the 30 seconds(test email with time-stamp being sent from there) but no response returned.  Get method does resolve the querystring but switch to using post and no data at the target page.  No response from the target page gets back to initiating page.  As stated, this works fine on the current server running Server 2003.  I've gone through roles, proxycfg(direct access as with the current server), it's a page calling a page in the same directory.  In the IIS manager I have set the ISAPI restrictions to allowed for c:\windows\system32\msxml3.dll.  I have started WinHttpAutoProxySvc.   Perhaps a specific feature I need to install or a service to run or...?

error:

msxml3.dll error '80072ee2'

The operation timed out

/testXML_2.asp , line 26


line 26 is the xml.send line

 

Simple code being tested to get the xml working on the new server(testXML_2.asp):

IF UCASE(Request.ServerVariables("HTTPS")) = "ON" THEN
    vWork2 = cfgURLBaseSecure & cfgURLDir
ELSE
    vWork2 = cfgURLBase & cfgURLDir
END IF

vXMLAdr = vWork2 & "/testXML.asp"
vXMLStr = "?EC=E1234567890"

SET xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

vWork = vXMLAdr & vXMLStr
xml.open "GET", vWork, FALSE
xml.send

'xml.open "POST", vXMLAdr, FALSE
'xml.send vXMLStr

IF xml.status = 200 THEN
    vReturn = xml.responseText
ELSE
    vReturn = "FAIL"
END IF

 

 

Target page code(testXML.asp):

vWork2 = Request.QueryString("EC")
'vWork3 = Request.form("EC")

vWork = "testXML - Time: " & now() & "  querystring: " & vWork2 & "   form: " & vWork3
CALL SendErrorEmail("testXML - new",vWork,"")

Response.Write "Got There and Back"
Response.end

 

The reason the one ASP page is using the XML object to contact another is the main use of the target is AJAX with other pages but sometimes the system needs to perform the same function thus this method of interacting with the AJAX page via the system vs a user via a browser and I would prefer to keep the code in one place.  Perhaps there is an alternate I should be considering but the above scenario has been in production just fine for years now.

Any help?

Thanks in advance,

Ken

Get the output in List from the XML

$
0
0

I want the following output in form of List:

TOCNumTOCDescription
Toc4094548241.1 AluminaAluminum oxide
Toc4094548251.1.1 AntipersperantAluminum chlorohydrate
Toc4094548261.1.1.1 Aqua regia1:3 mixture of nitric and   hydrochloric acids 
Toc4094548271.1.1.1.1 BarytesBarium sulfate 
Toc4094548281.1.1.1.1.1 BauxiteHydrated aluminum oxide 
Toc4094548291.1.1.1.1.1.1 BrimstoneSulfur
Toc4094548301.1.1.1.1.1.1.1 CalgonCalcium hexametaphosphate
Toc4094548311.1.1.1.1.1.1.1.1.1 Club sodaCarbonic acid
Toc4094548331.2 DolomiteCalcium magnesium carbonate
Toc4094548351.3 Easy-off oven cleanerSodium hydroxide
Toc4094548371.4 Fertilizer componentAmmonium nitrate

from the XML provided at the following location: https://sites.google.com/site/aryabhatainfinity/xml/Qry.xml?attredirects=0&d=1

Unable to export an xml from excel 2003

$
0
0

Hi.
First of all sorry for my English.
Today they come in my hands an xml file (I am as rookie as possible in xml).
In this file we want to make some changes and after this export it again in xml.
I don't have any problem to open the file with excel but until now i am unable to make export to the specific files.
The "schema" from my xml is like the picture in the bottom (delete the names to avoid any possible problems)
When i have only 1 line the export work perfect or when i assign only the "Root-2".
When i try to export all of then i receive error.Thanks for your help because i am completely lost

IXMLDOMDocumentPtr save method is saving the tags in single row.

$
0
0

When i am trying to create a IXMLDOMDocumentPtr and using appendchild populating the domdocument object and finally saving it to the xmlfile the appended rows comes in a single row if we open in notepad.

here is the code snippet:


IXMLDOMElementPtr pXMLDOMElement;
pXMLDOMElement = pXMLDOMNodeRSData->appendChild(pXMLDOMDoc->createElement("z:row"));
pXMLDOMElement->setAttribute("PARAMETERS_KEY", bstrParamKey);
pXMLDOMElement->setAttribute("PARAMETERS_SECTION", paramOrder);
pXMLDOMElement->setAttribute("PARAMETERS_VALUE", paramValue);
pXMLDOMElement->setAttribute("DESCRIPTION", paramDesc);

hr = pXMLDOMDoc->save(tszFilePath);

shown as below:

<z:row PARAMETERS_KEY="ECL_PROFILE_ID" PARAMETERS_SECTION="100" PARAMETERS_VALUE="1" DESCRIPTION="Sucursal CLP"/><z:row PARAMETERS_KEY="ECL_PROFILE_ID" PARAMETERS_SECTION="101" PARAMETERS_VALUE="1" DESCRIPTION="Sucursal USD"/>

XSLT producing different results via debugger and xslt.Transform()

$
0
0

I'm producing the body of an email via an xsl. I've been having a problem with the html nested inside a <table> tag not displaying correctly. With a bit of help from the good folks over at the asp.net forums, I've tracked the problem down to getting different results if I run the xsl via the debugger or via a compiled transform.

When I debug the xsl it produces

      <table border="1" cellpadding="4" cellspacing="0" style="..." id="tmsEmailTable">
        <tr>
          <th width="50%" align="center"><b>Issue</b></th>
          <th width="50%" align="center"><b>Resolution</b></th>
        </tr>
        <tr>
          <td>Missing Acknowledgement date</td>
          <td><p> Test test</p></td>
        </tr>
        <tr>
          <td>Missing Agent and/or Seller signature</td>
        ....
    </table>

And that's absolutely correct and displays perfectly if I save the result as an html file. But when I use xslt.Transform(..), where xslt is a compiled transform, it produces

<table border="1" cellpadding="4" cellspacing="0" style="..." id="tmsEmailTable">
            <tr><th width="50%" align="center"><b>Issue</b></th><th width="50%" align="center"><b>Resolution</b></th></tr>
            <tr>
                <td>
                    Missing Acknowledgement date
                </td>
                <td></td>
            </tr>
        </table>
    </p><p> Test test</p></td></tr><tr>
        <td>Missing Agent and/or Seller signature</td>
        <td>
     .....
    </table>

And to make it even more interesting, that extra </table> tag and the misplaced table data only occur on the first table row, but the table rows are generated by an xsl:for-each.

The relevant bit of the xsl is:

          <table border="1" cellpadding="4" cellspacing="0" style="..." id="tmsEmailTable">
            <tr>
              <th width="50%" align="center">
                <b>Issue</b>
              </th>
              <th width="50%" align="center">
                <b>Resolution</b>
              </th>
            </tr>

            <xsl:for-each select="emailbody/checklist/item">
              <xsl:if test="string-length(select='issue')>0">
                <tr>
                  <td>
                    <xsl:value-of select="issue" disable-output-escaping="yes" />
                  </td>
                  <td>
                    <xsl:value-of select="resolution" disable-output-escaping="yes" />
                  </td>
                </tr>
              </xsl:if>
             </xsl:for-each>

          </table>

The code that generates the compiled transform and the (incorrect) output is:

            Dim xslt As XslCompiledTransform = New XslCompiledTransform(True)
            'Dim xslt As XslTransform = New XslTransform

            xslt.Load(templatePath) 

            Dim objStream As Stream = New MemoryStream(UTF8Encoding.UTF8.GetBytes(xmlData))
            Dim strbldrXML As StringBuilder = New StringBuilder()
            Dim objXmlReader As XmlReader = XmlReader.Create(objStream)
            Dim objXmlWriter As XmlWriter = XmlWriter.Create(strbldrXML)

            xslt.Transform(objXmlReader, objXmlWriter)

I've checked that templatePath is pointing to the right file, and the source file I'm debugging the xsl against was copied from the xmlData parameter, so I know the same stuff is getting fed into it.

I've been chasing this for days, and I'm about ready to quit and go get a job at a fast food joint. I'm not wonderful with xsl in general, or xsl in .NET in particular. Somebody PLEASE tell me I'm doing something stupid....


Rebecca M. Riordan

Importing complex xml into a DataSet

$
0
0

(A prolific PowerShell poster suggested I come over here....)

I have a schema but it doesn't import correctly into a DataSet with the expected table names.

There is more but I think if this gets solved the rest will, what am I doing wrong with the table names?

My PowerShell code (actually, the same thing happens with c#):

clear-host

$dsXml = new-object "System.Data.DataSet"
$dsXml.ReadXmlSchema("C:\temp\xml\mySchemaTest.xsd")
$dsXml.ReadXml("c:\temp\xml\myXmlTest.xml", 'ReadSchema')


Write-Host "Table names in dataset"
Write-Host "======================"
foreach ($table in $dsXml.Tables)
{
	Write-Host $table.TableName
}

The schema (tested as valid)

<?xml version="1.0" encoding="utf-8"?><xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"><xs:element name="products"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="books"><xs:complexType><xs:sequence><xs:element minOccurs="0" maxOccurs="unbounded" name="item"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="title" type="xs:string" /><xs:element minOccurs="0" name="pageCount" type="xs:string" /><xs:element minOccurs="0" name="price" type="xs:integer" /></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element><xs:element minOccurs="0" name="fruits"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="item"><xs:complexType><xs:sequence><xs:element minOccurs="0" name="type" type="xs:string" /><xs:element minOccurs="0" name="color" type="xs:string" /><xs:element minOccurs="0" name="price" type="xs:string" /></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element></xs:sequence></xs:complexType></xs:element></xs:schema>

result (I only expected 2 tables, all my data is actually in the table "items" in an all messed up way):

ReadSchema
Table names in dataset
======================
books
item
fruits

Grouping within a group in XSLT 1.0

$
0
0

Hi,

I have the below XML, from which I need to generate multiple groups within groups.

My sample XML:

<XmlContent>
<SalesInvoices2>
<NewDataSet>
<Table>
  <F1>ID</F1>
  <F2>NumberOfEntries</F2>
  <F3>JournalID</F3>
  <F4>Description</F4>
  <F5>TransactionID</F5>
  <F6>SourceID</F6>
  <F7>RecordID</F7>
  <F8>AccountID</F8>
  <F9>CreditAmount</F9>
  </Table>
<Table>
  <F1>1</F1>
  <F2>4</F2>
  <F3>10</F3>
  <F4>53-IX-90 Volkwagen Golf 1</F4>
  <F5>1</F5>
  <F6>4</F6>
  <F7>1</F7>
  <F8>100</F8>
  <F9>1000.28</F9>
  </Table>
<Table>
  <F1>1</F1>
  <F2>4</F2>
  <F3>10</F3>
  <F4>53-IX-90 Volkwagen Golf 1</F4>
  <F5>1</F5>
  <F6>4</F6>
  <F7>2</F7>
  <F8>101</F8>
  <F9>1089.87</F9>
  </Table>
<Table>
  <F1>1</F1>
  <F2>4</F2>
  <F3>10</F3>
  <F4>53-IX-90 Volkwagen Golf 1</F4>
  <F5>1</F5>
  <F6>4</F6>
  <F7>3</F7>
  <F8>102</F8>
  <F9>1090.87</F9>
  </Table>
<Table>
  <F1>1</F1>
  <F2>4</F2>
  <F3>10</F3>
  <F4>53-IX-90 Volkwagen Golf 1</F4>
  <F5>2</F5>
  <F6>6</F6>
  <F7>4</F7>
  <F8>103</F8>
  <F9>1091.87</F9>
  </Table>
<Table>
  <F1>1</F1>
  <F2>4</F2>
  <F3>10</F3>
  <F4>53-IX-90 Volkwagen Golf 1</F4>
  <F5>2</F5>
  <F6>6</F6>
  <F7>5</F7>
  <F8>104</F8>
  <F9>1092.87</F9>
  </Table>
<Table>
  <F1>3</F1>
  <F2>4</F2>
  <F3>12</F3>
  <F4>53-IX-90 Volkwagen Golf 5</F4>
  <F5>3</F5>
  <F6>5</F6>
  <F7>6</F7>
  <F8>105</F8>
  <F9>1093.87</F9>
  </Table>
<Table>
  <F1>3</F1>
  <F2>4</F2>
  <F3>12</F3>
  <F4>53-IX-90 Volkwagen Golf 5</F4>
  <F5>3</F5>
  <F6>5</F6>
  <F7>7</F7>
  <F8>106</F8>
  <F9>1094.87</F9>
  </Table>
<Table>
  <F1>3</F1>
  <F2>4</F2>
  <F3>12</F3>
  <F4>53-IX-90 Volkwagen Golf 5</F4>
  <F5>3</F5>
  <F6>5</F6>
  <F7>8</F7>
  <F8>107</F8>
  <F9>1095.87</F9>
  </Table>
<Table>
  <F1>3</F1>
  <F2>4</F2>
  <F3>12</F3>
  <F4>53-IX-90 Volkwagen Golf 5</F4>
  <F5>3</F5>
  <F6>5</F6>
  <F7>9</F7>
  <F8>108</F8>
  <F9>1096.87</F9>
  </Table>
<Table>
  <F1>3</F1>
  <F2>4</F2>
  <F3>12</F3>
  <F4>53-IX-90 Volkwagen Golf 5</F4>
  <F5>4</F5>
  <F6>7</F6>
  <F7>10</F7>
  <F8>109</F8>
  <F9>1097.87</F9>
  </Table>
<Table>
  <F1>3</F1>
  <F2>4</F2>
  <F3>12</F3>
  <F4>53-IX-90 Volkwagen Golf 5</F4>
  <F5>4</F5>
  <F6>7</F6>
  <F7>11</F7>
  <F8>110</F8>
  <F9>1098.87</F9>
  </Table>
</NewDataSet>
  </SalesInvoices2>
  </XmlContent>

Expected Output:

<!-- Journal- Repeats for each unique set of journal ID (F3) -->

 <Journal>    
      <JournalId>
        <xsl:value-of select="F3"/>
      </JournalId>
      <Description>
        <xsl:value-of select="F4"/>
      </Description>
     
      <!-- Transaction - Repeats for each unique set of transaction ID (F5) within Journal-->
      <Transaction>
        <TransactionId>
          <xsl:value-of select="F5"/>
        </TransactionId>
        <SourceID>
          <xsl:value-of select="F6"/>
        </SourceID>
        <!-- Line - Repeats within each Transaction for each Record ID(F7)  -->
        <Line>
          <LineNumber>
            <xsl:value-of select="F6"/>
          </LineNumber>
          <OrderDate>
            <xsl:value-of select="F7"/>
          </OrderDate>
          <ProductCode>
            <xsl:value-of select="F8"/>
          </ProductCode>
          <ProductDescription>
            <xsl:value-of select="F9"/>
          </ProductDescription>
        </Line>
      </Transaction>
 </Journal>

I had tried the below XSLT - which is not working as expected, however with slight changes to the approach, I am able to get the one outer loop , i.e., Journal would get repeated twice, but not other elements within that.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
    <xsl:apply-templates select="XmlContent/SalesInvoices2"/>
  </xsl:template>
  <xsl:key name="EntryId" match="Table" use="F3" />
  <xsl:template match="NewDataSet">
    <NewDataSet>
      <xsl:apply-templates select="//Table[position()>1 and generate-id(.) = generate-id(key('EntryId', F3)[1])]" />
    </NewDataSet>
  </xsl:template>

  <xsl:template name="Table" match="Table">
    <NumberOfEntries>
        <xsl:value-of select="F2"/>
      </NumberOfEntries>
    <!-- Repeats - Journal -->
    <Journal>
      <JournalId>
        <xsl:value-of select="F3"/>
      </JournalId>
      <Description>
        <xsl:value-of select="F4"/>
      </Description>

      <!-- Repeats - Transaction -->
      <xsl:for-each select="key('EntryId', concat(F3,'|',F5[1]))">
        <Transaction>
          <TransactionId>
            <xsl:value-of select="F5"/>
          </TransactionId>
          <SourceID>
            <xsl:value-of select="F6"/>
          </SourceID>
          <!-- Repeats - Line -->
          <xsl:for-each select="key('EntryId', F3)">
            <Line>
              <LineNumber>
                <xsl:value-of select="F6"/>
              </LineNumber>
              <OrderDate>
                <xsl:value-of select="F7"/>
              </OrderDate>
              <ProductCode>
                <xsl:value-of select="F8"/>
              </ProductCode>
              <ProductDescription>
                <xsl:value-of select="F9"/>
              </ProductDescription>
            </Line>
       </xsl:for-each>
        </Transaction>
        </xsl:for-each>      
    </Journal>
   </xsl:template>
</xsl:stylesheet>

In the given sample - Journal should get repeated twice and within first Journal set of elements - I should get two transaction set of elements within the first set of transaction there should be 3 Line set of elements and in the second transaction set there should be 2 Line set of elements.

Could you please help me on the solution, how I can have multiple groups and loop though the group and create another group within already constructed groups.


Rpaul



XMLDocument.Validate works on some machines but not on others

$
0
0

Hi All

 

I have a problem which I cannot Solve ,  I have a routine that Validates a node in a document  against a XSD file using the XmlDocument.Validate  method. This works fine on several machines but on a different network using the Same Document and schema files validate fails  with a validation exception element not found . I cannot figure out why the exact same files and application should be successful on one machine and unsuccessfull on another. I have used Filemon to see if their are ACCESS DENIED problems but there are none.

 

I have reinstalled the framework 2.0, to no avail

 

Regards

 

nested for-each not working

$
0
0

Hello all. I am studying XSLT in school and need some help.

Display the following: Software titles for each operating system sorted by category. Sorting is not the problem. I am having an issue with displaying software titles for each operating system. Here is the XML and the XSLT.

<?xml version="1.0"?><!-- Note: For many of the wonders, the experts do not agree on precise dates or construction dimensions.  In these cases, I chose a year or dimension in the middle of the range so all attributes could be numeric. --><software_inventory><software xmlns:xsi="Software.xsd"><title>Adobe Photoshop</title><vendor>Adobe</vendor><category>Graphics</category><support_platforms><Platform>Windows 7</Platform><Platform>Windows 8</Platform><Platform>Windows 8.1</Platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 2GB Hard Drive" Software_Requiremnts="32/64 bit" Price="399">CS 5.5</Version></Approved_Versions></software><software><title>Winzip</title><vendor>Winzip International</vendor><category>Utility</category><support_platforms><platform>Windows Vista</platform><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="2GB Ram 250MB Hard Drive" Software_Requiremnts="32/64 bit" Price="29.99">19</Version></Approved_Versions></software>

There are more titles in the XML, but I didn't include them.

Here is the XSLT

<h1>Software Titles for each operating system, sorted by category</h1><table border="1"><tr><th>Software Title</th><th>Operating System</th><th>Category</th></tr><xsl:for-each select="software_inventory/software"><xsl:sort select="support_platforms/platform"/><xsl:sort select="category"/><tr><td><xsl:value-of select="title"/></td><td><xsl:for-each select="support_platforms/platform"><xsl:value-of select="platform"/><xsl:text>&#13;</xsl:text></xsl:for-each></td><td><xsl:value-of select="category"/></td></tr></xsl:for-each></table>

Here is a screen shot of the output. What I would like is for each Platform / operating system to show in the same cell, so the adjacent cells will grow taller to accommodate. 

What am I doing wrong?

Locating data in my XML file using C#

$
0
0

Hi !

I have a XML file. Here is a snippet:

<Layers Count="9"><Layer Name="layer0" Type="Polygon"><OverlapNames Count="2"><OverlapName Name="layer1"/><OverlapName Name="layer2"/></OverlapNames><CommonNames Count="0"></CommonNames><SnapNames Count="1"><SnapName Name="layer3"/></SnapNames></Layer>

Now, if I have a "layer" is there a quick way to find the node "Layer" that name a name "layer0".

Secondly, is there a way to not only locate the node but return true if the "type" is a certain value? In the above example layer0 is a polygon. So if I encounter a point entity on layer0 and I try to find a layer where name="layer0" and type="point" it should return empty.

Thanks for clarification on right way to parse the XML data file to locate the information I need.

Andrew

Finding an entry where I have two values each in different nodes

$
0
0

Hi

Can I do this with one XPath? If I have "layer1" and "layer2" ....

Layers/Layer[@Name=\"layer1\"]  <---- This has to be true. But also ....

Layers/Layer/SnapNames/SnapName[@Name=\"layer2\"] <---- This has to be true

I did it like this:

                                    // Find main node
                                    XmlNode nodeLayer = xmlOrbis.SelectSingleNode(String.Format("Layers/Layer[@Name=\"{0}\"]", strLayer));
                                    if(nodeLayer != null)
                                    {
                                        String strLayer2 = m_dictLayers[pSegment2.layerID];
                                        XmlNode nodeLayer2 = xmlOrbis.SelectSingleNode(String.Format("SnapsNames/SnapName[@Name=\"{0}\"]", strLayer2));
                                        if(nodeLayer2 == null)
                                        {
                                        }
                                    }

Can I simplify it into one call? Something like:

XmlNode nodeLayer = xmlOrbis.SelectSingleNode(String.Format("Layers/Layer[@Name=\"{0}\"]/SnapNames/SnapName[@Name=\"{1}\"]", strLayer, strLayer2));

I don't know if that is viable ...

Andrew




XSLT - Selecting Min, Max, and Avg Attribute Values - Need Data from different Levels

$
0
0

Hello all. I thing my problem is that the attribute is on a couple of nodes down from the node that I need to select. Also, I need to pull values from different levels. Not sure how to construct the XPath.

Here is my XML:

<?xml version="1.0"?><software_inventory><software xmlns:xsi="Software.xsd"><title>Adobe Photoshop</title><vendor>Adobe</vendor><category>Graphics</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform><platform>Linux</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 2GB Hard Drive" Software_Requiremnts="32/64 bit" Price="399">CS 5.5</Version></Approved_Versions></software><software><title>Winzip</title><vendor>Winzip International</vendor><category>Utility</category><support_platforms><platform>Windows Vista</platform><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="2GB Ram 250MB Hard Drive" Software_Requiremnts="32/64 bit" Price="29.99">19</Version></Approved_Versions></software><software><title>Office 365</title><vendor>Microsoft</vendor><category>Productivity</category><support_platforms><platform>Windows Vista</platform><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 2GB Hard Drive" Software_Requiremnts="32/64 bit" Price="99">Office 365</Version></Approved_Versions></software><software><title>Visual Studio</title><vendor>Microsoft</vendor><category>Development</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 2GB Hard Drive" Software_Requiremnts="32/64 bit" Price="1199">2013</Version></Approved_Versions></software><software><title>Google Chrome</title><vendor>Google</vendor><category>Productivity</category><support_platforms><platforms>Windows Vista</platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="1GB Ram 250MB Hard Drive" Software_Requiremnts="32/64 bit" Price="0">23</Version></Approved_Versions></software><software><title>Microsoft SQL Server 2012</title><vendor>Microsoft</vendor><category>DBMS</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform><platform>Windows Server 2012</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 4GB Hard Drive" Software_Requiremnts="64 bit" Price="3990">2012</Version></Approved_Versions></software><software><title>Microsoft Paint</title><vendor>Microsoft</vendor><category>Graphics</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform><platform>Linux</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="16GB Ram 1TB Hard Drive" Software_Requiremnts="32/64 bit" Price="1000000">22</Version></Approved_Versions></software><software><title>Notepad</title><vendor>Microsoft</vendor><category>Development</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="32GB Ram 500MB Hard Drive" Software_Requiremnts="32/64 bit" Price="500000">3</Version></Approved_Versions></software><software><title>Oracle Database</title><vendor>Oracle</vendor><category>DBMS</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform><platform>Windows Server 2012</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="8GB Ram 4GB Hard Drive" Software_Requiremnts="64 bit" Price="4000">Enterprise Edition</Version><Version Hardware_Requirements="8GB Ram 3GB Hard Drive" Software_Requiremnts="64 bit" Price="3000">Standard Edition</Version></Approved_Versions></software><software><title>Adobe Dreamweaver</title><vendor>Adobe</vendor><category>Development</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="2GB Ram 500MB Hard Drive" Software_Requiremnts="32/64 bit" Price="299">CS5</Version></Approved_Versions></software><software><title>Adobe Fireworks</title><vendor>Adobe</vendor><category>Graphics</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="2GB Ram 500MB Hard Drive" Software_Requiremnts="32/64 bit" Price="1">CS5</Version></Approved_Versions></software><software><title>Adobe Flash</title><vendor>Adobe</vendor><category>Development</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 1GB Hard Drive" Software_Requiremnts="32/64 bit" Price="499">CS5</Version></Approved_Versions></software><software><title>Adobe Illustrator</title><vendor>Adobe</vendor><category>Development</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 500MB Hard Drive" Software_Requiremnts="32/64 bit" Price="499">CS5</Version></Approved_Versions></software><software><title>Google Earth Pro</title><vendor>Google</vendor><category>Productivity</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 500MB Hard Drive" Software_Requiremnts="32/64 bit" Price="999">14</Version></Approved_Versions></software><software><title>Eclipse</title><vendor>The Eclipse Foundation</vendor><category>Development</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="4GB Ram 500MB Hard Drive" Software_Requiremnts="32/64 bit" Price="0">12</Version></Approved_Versions></software><software><title>Candy Crush Saga</title><vendor>King.com ltd.</vendor><category>Productivity</category><support_platforms><platform>Windows 7</platform><platform>Windows 8</platform><platform>Windows 8.1</platform></support_platforms><Approved_Versions><Version Hardware_Requirements="32GB Ram 500GB Hard Drive" Software_Requiremnts="32/64 bit" Price="2000000">99</Version></Approved_Versions></software></software_inventory>

I need to select all graphics software (category) that runs on linux (platform) and I need the minimum, maximum, and average price (version/@price). This seems very complex to me, and I really need some help.

Thanks,

David

Viewing all 935 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>