|
I was hoping someone could give me a hand with this. I'd like to convert a standard XML file into one that groups the data by one of the data elements.
Here is a sample of data I'd be using:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Inventory>
<Item>
<producttype>Book</producttype>
<productname>A Connecticut Yankee in King Arthur's Court</productname>
<artistfirstname>Mark</artistfirstname>
<artistlastname>Twain</artistlastname>
<description>A Connecticut Yankee travels back to King Arthur's court and adventure ensues. Fun, fun, fun.</description>
<company>Pocket Books</company>
<year>1889</year>
<productid>978-1416534730</productid>
<price>4.95</price>
<image/>
</Item>
<Item>
<producttype>Book</producttype>
<productname>A Farewell To Arms</productname>
<artistfirstname>Ernest</artistfirstname>
<artistlastname>Hemingway</artistlastname>
<description>The tragic tale of love and loss during WWI.</description>
<company>Charles Scribner's Sons</company>
<year>1929</year>
<productid>978-0684837888</productid>
<price>18.15</price>
<image href="file://images/978-0684837888.jpg"/>
</Item>
<Item>
<producttype>Book</producttype>
<productname>A Portrait of the Artist as a Young Man</productname>
<artistfirstname>James</artistfirstname>
<artistlastname>Joyce</artistlastname>
<description>A a fictionalized memoir of Joyce's alter ego, Stephen Daedelus, describing his coming of age in Dublin.</description>
<company>Everyman's Library</company>
<year>1916</year>
<productid>978-0679405757</productid>
<price>14.25</price>
<image href="file://images/978-0679405757.jpg"/>
</Item>
<Item>
<producttype>Audiobook</producttype>
<productname>A Tale of Two Cities</productname>
<artistfirstname>Charles</artistfirstname>
<artistlastname>Dickens</artistlastname>
<description>Classic telling of life in two cities, London and Paris, during the upheaval of the French Revolution.</description>
<company>Blackstone Audiobooks</company>
<year>2005</year>
<productid>978-0786180394</productid>
<price>19.77</price>
<image href="file://images/978-0786180394.jpg"/>
</Item>
<Item>
<producttype>Audiobook</producttype>
<productname>Anna Karenina</productname>
<artistfirstname>Leo</artistfirstname>
<artistlastname>Tolstoy</artistlastname>
<description>Audiobook version of the intricate intrigue of love and scandal in high society of Czarist Russia.</description>
<company>Naxos Audiobooks</company>
<year>1999</year>
<productid>978-9626340813</productid>
<price>20.55</price>
<image href="file://images/978-9626340813.jpg"/>
</Item>
</Inventory>
I'd like to end up with something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Inventory>
<category>
<type>Book</type>
<Item>
<productname>A Connecticut Yankee in King Arthur's Court</productname>
<artistfirstname>Mark</artistfirstname>
<artistlastname>Twain</artistlastname>
<description>A Connecticut Yankee travels back to King Arthur's court and adventure ensues. Fun, fun, fun.</description>
<company>Pocket Books</company>
<year>1889</year>
<productid>978-1416534730</productid>
<price>4.95</price>
<image/>
</Item>
<Item>
<productname>A Farewell To Arms</productname>
<artistfirstname>Ernest</artistfirstname>
<artistlastname>Hemingway</artistlastname>
<description>The tragic tale of love and loss during WWI.</description>
<company>Charles Scribner's Sons</company>
<year>1929</year>
<productid>978-0684837888</productid>
<price>18.15</price>
<image href="file://images/978-0684837888.jpg"/>
</Item>
<Item>
<productname>A Portrait of the Artist as a Young Man</productname>
<artistfirstname>James</artistfirstname>
<artistlastname>Joyce</artistlastname>
<description>A a fictionalized memoir of Joyce's alter ego, Stephen Daedelus, describing
his coming of age in Dublin.</description>
<company>Everyman's Library</company>
<year>1916</year>
<productid>978-0679405757</productid>
<price>14.25</price>
<image href="file://images/978-0679405757.jpg"/>
</Item>
</category>
<category>
<type>Audiobook</type>
<Item>
<productname>A Tale of Two Cities</productname>
<artistfirstname>Charles</artistfirstname>
<artistlastname>Dickens</artistlastname>
<description>Classic telling of life in two cities, London and Paris, during the
upheaval of the French Revolution.</description>
<company>Blackstone Audiobooks</company>
<year>2005</year>
<productid>978-0786180394</productid>
<price>19.77</price>
<image href="file://images/978-0786180394.jpg"/>
</Item>
<Item>
<productname>Anna Karenina</productname>
<artistfirstname>Leo</artistfirstname>
<artistlastname>Tolstoy</artistlastname>
<description>Audiobook version of the intricate intrigue of love and scandal in high
society of Czarist Russia.</description>
<company>Naxos Audiobooks</company>
<year>1999</year>
<productid>978-9626340813</productid>
<price>20.55</price>
<image href="file://images/978-9626340813.jpg"/>
</Item>
</category>
</Inventory>
Does anyone know how to write an XSLT to create this kind of grouping?
If you have any suggestions, I'd entertain any options.
Thanks
|
|
|
|
|
blindcapt wrote: Does anyone know how to write an XSLT to create this kind of grouping?
What kind of grouping? I'm not going to reverse engineer your XML to decipher the problem statement for you. If you understand your problem clearly, you should have no trouble stating it in a post.
|
|
|
|
|
Each record contains these elements: producttype, productname, productid, productprice
I want the elements to group under the producttype element, such as:
Original:
<products>
<item>
producttype
productname
productid
productprice
</item>
<item>
producttype
productname
productid
productprice
</item>
</products>
Desired:
<products>
<category>
<producttype></producttype>
<item>
productname
productid
productprice
</item>
<item>
productname
productid
productprice
</item>
</category>
<category>
<producttype></producttype>
<item>
productname
productid
productprice
</item>
<item>
productname
productid
productprice
</item>
</category>
</products>
|
|
|
|
|
The technique for this is known as the Muenchian Method (or Muenchian grouping[^]) and it involves the use of xsl:key in a rather clever way.
I just love Koalas - they go great with Bacon.
|
|
|
|
|
Hey all,
Are the following three XPath expression equivalent?
resolve-uri(@url)
resolve-uri(@url, base-uri(.))
resolve-uri(@url, static-base-uri())
Cheers!
Lea Hayes
|
|
|
|
|
I need to extract some results from a XML file. The XML sort of like the below (each day has a record). The results are expected to be imported into a table with four columns (Month, Total rain for each month, highest temp for each month, lowest tem for each month) and 12 rows (for each month).
Can anyone help to provide some solutions? how to retrive and do simply calculation for this scenario? Many thanks.
<climatedata>
<lang>ENG</lang>
<stationdata day="1" month="1" year="2008">
<maxtemp description="Maximum Temperature" units="°C">8.80</maxtemp>
<mintemp description="Minimum Temperature" units="°C">3.90</mintemp>
<meantemp description="Mean Temperature" units="°C">6.40</meantemp>
<totalrain description="Total Rain" units="mm">0.00</totalrain>
<totalsnow description="Total Snow" units="cm">0.00</totalsnow>
<totalprecipitation description="Total Precipitation" units="mm">0.00</totalprecipitation>
<snowonground description="Snow on Ground" units="cm">0.00</snowonground>
<dirofmaxgust description="Direction of Maximum Gust" flag="E" units="10's Deg">6.00</dirofmaxgust>
<speedofmaxgust description="Speed of Maximum Gust" flag="E" units="km/h">54.00</speedofmaxgust>
<heatdegdays description="Heating Degree Days" units="°C">11.60</heatdegdays>
<cooldegdays description="Cooling Degree Days" units="°C">0.00</cooldegdays>
</stationdata>
modified on Tuesday, March 31, 2009 12:49 PM
|
|
|
|
|
<climatedata>
<lang>ENG</lang>
<stationdata day="1" month="1" year="2008">
<maxtemp description="Maximum Temperature" units="°C">8.80</maxtemp>
<mintemp description="Minimum Temperature" units="°C">3.90</mintemp>
<meantemp description="Mean Temperature" units="°C">6.40</meantemp>
<totalrain description="Total Rain" units="mm">0.00</totalrain>
</stationdata>
<stationdata day="2" month="1" year="2008">
<maxtemp description="Maximum Temperature" units="°C">7.60</maxtemp>
<mintemp description="Minimum Temperature" units="°C">2.60</mintemp>
<meantemp description="Mean Temperature" units="°C">5.10</meantemp>
<totalrain description="Total Rain" units="mm">9.40</totalrain>
</stationdata>
|
|
|
|
|
no one can help?
|
|
|
|
|
Hi guys!
I have a RelaxNG schema which defines a group of attributes called "common-attrs". Amongst these common attributes is the "xml:id" attribute which can be optionally applied to all elements within the schema.
Somehow, I need to make an exception to this rule. There is one element where all of the common attributes apply, but the "xml:id" attribute is required. How can I make an exception to this rule without having to manage to near identical common attribute groups?
Many thanks,
Lea Hayes
|
|
|
|
|
Hello,
I am developing quite complex workflow using SharePoint and Workflow foundation. The WF is started on a InfoPath form and through the process of the workflow values of fields are changed programaticaly in the infopath form.
So far I had only textboxes which I was changing using this method:
MemoryStream myInStream = new MemoryStream(lFile.OpenBinary());
XmlDocument myDoc = new XmlDocument();
myDoc.Load(myInStream);
XmlNode myRoot = myDoc.DocumentElement;
XmlNamespaceManager xmlNSManager = new XmlNamespaceManager(myDoc.NameTable);
XmlNode node = myRoot.SelectSingleNode("/my:fieldPath", xmlNSManager);
node.InnerText = "Text which I want to put in the textbox";
Now I have a Option button(Radio button), where you can swich from 3 values. I would like to be able to select one of these values programatically.
I've checked the XML definition of the InfoPath form and I thought that I could just use the InnerText property and insert the proper text(text of one of the choices). But that is not working.
I am new to InfoPath and I am not a member of any IP forums so I said I will try my luck here in CP
thank you for any suggestions
Honga
|
|
|
|
|
Can anyone possibly let me know,
how can i use superscript and subscript in an xml.
I need to insert a chemical formula . eg; H2SO4 where 2 and 4 are subscript and show them in an xml.
How could i do it?
Is there tags such as "sub" and "sup" that we can use in an xml.
For eg;
<rss>
<chemical>Sulphuric Acid
<formula>H2SO4
If any one has the solution, pls let me know
Aspiring Techie,
Vishnu Nath
|
|
|
|
|
XML is just markup, it doesn't specify how things should look. It sounds as if you might need a markup language directed towards chemical formulas. I did a search and found CML - Chemical Markup Language: http://www.ch.ic.ac.uk/rzepa/cml/[^]. Maybe that's what you're looking for.
Scott
|
|
|
|
|
I am trying to convert a xml file into a word document. For this i am using an xslt.
It looks like this:
*****XML FILE*****
<?xml version='1.0' encoding='utf-8'?><?mso-application progid='Word.Document'?>
<?xml-stylesheet type='text/xsl' href='C:\Documents and Settings\tejabhiramy.IDEAENTITY\Desktop\VCMData1\Projects/Teja\Ravi Shankar.yadavalli.xsl'?><contentInstance vcmId="d62dde7a94e8f110VgnVCM100000e601a8c0RCRD" vcmStatus="" vcmLogicalPath="/Teja" vcmName="Ravi Shankar.yadavalli" publishDate="" unpublishDate=""><contentTypeId>b1aade7a94e8f110VgnVCM100000e601a8c0____</contentTypeId><attribute name="name"><valueString>Ravi Shankar.yadavalli</valueString></attribute><attribute name="age"><valueString></valueString></attribute><attribute name="rank"><valueInt>9849</valueInt></attribute><classification><path><![CDATA[/Technical]]></path></classification><acl><entry name="vgnadmin" type="user"><grants><capability application="VCM" name="MODIFY_TAX_ASSOCS"/><capability application="VCM" name="RANKS_DELETE"/><capability application="VCM" name="MODIFY"/><capability application="VCM" name="MODIFY_ACL"/><capability application="VCM" name="DELETE"/><capability application="VCM" name="PROMOTE_AND_DEMOTE"/><capability application="VCM" name="SECURITY_READ"/><capability application="VCM" name="DEPLOY_AND_UNDEPLOY"/><capability application="VCM" name="RANKS_READ"/><capability application="VCM" name="SECURITY_WRITE"/><capability application="VCM" name="WORKFLOW_DEF_READ"/><capability application="VCM" name="RANKS_WRITE"/></grants></entry></acl></contentInstance>
*****XSLT File*****
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:w='http://schemas.microsoft.com/office/word/2003/wordml'
xmlns:wx='http://schemas.microsoft.com/office/word/2003/auxHint'>
<xsl:template match='/'>
<xsl:processing-instruction name='mso-application'>
<xsl:text>progid='Word.Document'</xsl:text>
</xsl:processing-instruction>
<w:wordDocument>
<xsl:attribute name='xml:space'>preserve</xsl:attribute>
<xsl:copy-of select='$styles-element'/>
<w:docPr><w:useXSLTWhenSaving/>
<w:saveThroughXSLT w:xslt='C:\Documents and Settings\tejabhiramy.IDEAENTITY\Desktop\VCMData1\Projects/Teja\ReverseRavi Shankar.yadavalli.xsl'/><w:documentProtection w:formatting='on' w:enforcement='on'/></w:docPr><w:body><xsl:apply-templates/></w:body></w:wordDocument></xsl:template>
<xsl:template match='contentInstance/contentTypeId/attribute'>
<w:p><w:pPr><w:pStyle w:val='Heading1'/></w:pPr>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:apply-templates/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:p>
</xsl:template>
<xsl:template match='attribute/valueString'>
<w:p>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:apply-templates/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:p></xsl:template>
<xsl:template match='attribute/valueString'>
<w:p><xsl:apply-templates/></w:p>
</xsl:template>
<xsl:template match='attribute/valueInt'>
<w:p>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:apply-templates/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:p>
</xsl:template>
<xsl:template match='attribute/valueString/text()'>
<w:r><w:rPr><w:rStyle w:val='attribute/valueString'/></w:rPr>
<w:t>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:value-of select='.'/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:t></w:r>
</xsl:template>
<xsl:template match='attribute/valueString/text()'>
<w:r><w:rPr>
<w:rStyle w:val='attribute/valueString'/>
</w:rPr><w:t>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:value-of select='.'/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt></w:t></w:r>
</xsl:template>
<xsl:template match='attribute/valueInt/text()'>
<w:r><w:rPr><w:rStyle w:val='attribute/valueInt'/></w:rPr>
<w:t>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:value-of select='.'/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:t></w:r>
</xsl:template>
<xsl:variable name='styles-element'><w:styles><w:style w:type='paragraph' w:default='on' w:styleId='Normal'><w:name w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:spacing w:after='360'/></w:pPr><w:rPr><wx:font wx:val='Times New Roman'/><w:sz w:val='24'/><w:sz-cs w:val='24'/><w:lang w:val='EN-US' w:fareast='EN-US' w:bidi='AR-SA'/></w:rPr></w:style><w:style w:type='paragraph' w:styleId='Heading1'><w:name w:val='heading 1'/><wx:uiName wx:val='Heading 1'/><w:basedOn w:val='Normal'/><w:next w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:pStyle w:val='Heading1'/><w:keepNext/><w:spacing w:before='240' w:after='60'/><w:outlineLvl w:val='0'/></w:pPr><w:rPr><w:rFonts w:ascii='Arial' w:h-ansi='Arial' w:cs='Arial'/><wx:font wx:val='Arial'/><w:b/><w:b-cs/><w:kern w:val='32'/><w:sz w:val='32'/><w:sz-cs w:val='32'/></w:rPr></w:style><w:style w:type='paragraph' w:styleId='Heading2'><w:name w:val='heading 2'/><wx:uiName wx:val='Heading 2'/><w:basedOn w:val='Normal'/><w:next w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:pStyle w:val='Heading2'/><w:keepNext/><w:spacing w:before='240' w:after='60'/><w:outlineLvl w:val='1'/></w:pPr><w:rPr><w:rFonts w:ascii='Arial' w:h-ansi='Arial' w:cs='Arial'/><wx:font wx:val='Arial'/><w:b/><w:b-cs/><w:i/><w:i-cs/><w:sz w:val='28'/><w:sz-cs w:val='28'/></w:rPr></w:style><w:style w:type='paragraph' w:styleId='Heading3'><w:name w:val='heading 3'/><wx:uiName wx:val='Heading 3'/><w:basedOn w:val='Normal'/><w:next w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:pStyle w:val='Heading3'/><w:keepNext/><w:spacing w:before='240' w:after='60'/><w:outlineLvl w:val='2'/></w:pPr><w:rPr><w:rFonts w:ascii='Arial' w:h-ansi='Arial' w:cs='Arial'/><wx:font wx:val='Arial'/><w:b/><w:b-cs/><w:sz w:val='26'/><w:sz-cs w:val='26'/></w:rPr></w:style><w:style w:type='character' w:default='on' w:styleId='DefaultParagraphFont'><w:name w:val='Default Paragraph Font'/><w:semiHidden/></w:style><w:style w:type='table' w:default='on' w:styleId='TableNormal'><w:name w:val='Normal Table'/><wx:uiName wx:val='Table Normal'/><w:semiHidden/><w:rPr><wx:font wx:val='Times New Roman'/></w:rPr><w:tblPr><w:tblInd w:w='0' w:type='dxa'/><w:tblCellMar><w:top w:w='0' w:type='dxa'/><w:left w:w='108' w:type='dxa'/><w:bottom w:w='0' w:type='dxa'/><w:right w:w='108' w:type='dxa'/></w:tblCellMar></w:tblPr></w:style><w:style w:type='list' w:default='on' w:styleId='NoList'><w:name w:val='No List'/><w:semiHidden/></w:style><w:style w:type='character' w:styleId='Strong'><w:name w:val='Strong'/><w:basedOn w:val='DefaultParagraphFont'/><w:rsid w:val='00664EF3'/><w:rPr><w:b/><w:b-cs/></w:rPr></w:style></w:styles></xsl:variable></xsl:stylesheet>
*****XSLT File*****
<xsl:stylesheet version='1.0'
xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
xmlns:w='http://schemas.microsoft.com/office/word/2003/wordml'
xmlns:wx='http://schemas.microsoft.com/office/word/2003/auxHint'>
<xsl:template match='/'>
<xsl:processing-instruction name='mso-application'>
<xsl:text>progid='Word.Document'</xsl:text>
</xsl:processing-instruction>
<w:wordDocument>
<xsl:attribute name='xml:space'>preserve</xsl:attribute>
<xsl:copy-of select='$styles-element'/>
<w:docPr><w:useXSLTWhenSaving/>
<w:saveThroughXSLT w:xslt='C:\Documents and Settings\tejabhiramy.IDEAENTITY\Desktop\VCMData1\Projects/Teja\ReverseRavi Shankar.yadavalli.xsl'/><w:documentProtection w:formatting='on' w:enforcement='on'/></w:docPr><w:body><xsl:apply-templates/></w:body></w:wordDocument></xsl:template>
<xsl:template match='contentInstance/contentTypeId/attribute'>
<w:p><w:pPr><w:pStyle w:val='Heading1'/></w:pPr>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:apply-templates/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:p>
</xsl:template>
<xsl:template match='attribute/valueString'>
<w:p>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:apply-templates/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:p></xsl:template>
<xsl:template match='attribute/valueString'>
<w:p><xsl:apply-templates/></w:p>
</xsl:template>
<xsl:template match='attribute/valueInt'>
<w:p>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:apply-templates/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:p>
</xsl:template>
<xsl:template match='attribute/valueString/text()'>
<w:r><w:rPr><w:rStyle w:val='attribute/valueString'/></w:rPr>
<w:t>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:value-of select='.'/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:t></w:r>
</xsl:template>
<xsl:template match='attribute/valueString/text()'>
<w:r><w:rPr>
<w:rStyle w:val='attribute/valueString'/>
</w:rPr><w:t>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:value-of select='.'/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt></w:t></w:r>
</xsl:template>
<xsl:template match='attribute/valueInt/text()'>
<w:r><w:rPr><w:rStyle w:val='attribute/valueInt'/></w:rPr>
<w:t>
<w:Sdt ShowingPlcHdr="t" DocPart="DefaultPlaceholder_22675703" ID="2075628"><p><span><span><xsl:value-of select='.'/></span></span><w:sdtPr></w:sdtPr></p></w:Sdt>
</w:t></w:r>
</xsl:template>
<xsl:variable name='styles-element'><w:styles><w:style w:type='paragraph' w:default='on' w:styleId='Normal'><w:name w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:spacing w:after='360'/></w:pPr><w:rPr><wx:font wx:val='Times New Roman'/><w:sz w:val='24'/><w:sz-cs w:val='24'/><w:lang w:val='EN-US' w:fareast='EN-US' w:bidi='AR-SA'/></w:rPr></w:style><w:style w:type='paragraph' w:styleId='Heading1'><w:name w:val='heading 1'/><wx:uiName wx:val='Heading 1'/><w:basedOn w:val='Normal'/><w:next w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:pStyle w:val='Heading1'/><w:keepNext/><w:spacing w:before='240' w:after='60'/><w:outlineLvl w:val='0'/></w:pPr><w:rPr><w:rFonts w:ascii='Arial' w:h-ansi='Arial' w:cs='Arial'/><wx:font wx:val='Arial'/><w:b/><w:b-cs/><w:kern w:val='32'/><w:sz w:val='32'/><w:sz-cs w:val='32'/></w:rPr></w:style><w:style w:type='paragraph' w:styleId='Heading2'><w:name w:val='heading 2'/><wx:uiName wx:val='Heading 2'/><w:basedOn w:val='Normal'/><w:next w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:pStyle w:val='Heading2'/><w:keepNext/><w:spacing w:before='240' w:after='60'/><w:outlineLvl w:val='1'/></w:pPr><w:rPr><w:rFonts w:ascii='Arial' w:h-ansi='Arial' w:cs='Arial'/><wx:font wx:val='Arial'/><w:b/><w:b-cs/><w:i/><w:i-cs/><w:sz w:val='28'/><w:sz-cs w:val='28'/></w:rPr></w:style><w:style w:type='paragraph' w:styleId='Heading3'><w:name w:val='heading 3'/><wx:uiName wx:val='Heading 3'/><w:basedOn w:val='Normal'/><w:next w:val='Normal'/><w:rsid w:val='00664EF3'/><w:pPr><w:pStyle w:val='Heading3'/><w:keepNext/><w:spacing w:before='240' w:after='60'/><w:outlineLvl w:val='2'/></w:pPr><w:rPr><w:rFonts w:ascii='Arial' w:h-ansi='Arial' w:cs='Arial'/><wx:font wx:val='Arial'/><w:b/><w:b-cs/><w:sz w:val='26'/><w:sz-cs w:val='26'/></w:rPr></w:style><w:style w:type='character' w:default='on' w:styleId='DefaultParagraphFont'><w:name w:val='Default Paragraph Font'/><w:semiHidden/></w:style><w:style w:type='table' w:default='on' w:styleId='TableNormal'><w:name w:val='Normal Table'/><wx:uiName wx:val='Table Normal'/><w:semiHidden/><w:rPr><wx:font wx:val='Times New Roman'/></w:rPr><w:tblPr><w:tblInd w:w='0' w:type='dxa'/><w:tblCellMar><w:top w:w='0' w:type='dxa'/><w:left w:w='108' w:type='dxa'/><w:bottom w:w='0' w:type='dxa'/><w:right w:w='108' w:type='dxa'/></w:tblCellMar></w:tblPr></w:style><w:style w:type='list' w:default='on' w:styleId='NoList'><w:name w:val='No List'/><w:semiHidden/></w:style><w:style w:type='character' w:styleId='Strong'><w:name w:val='Strong'/><w:basedOn w:val='DefaultParagraphFont'/><w:rsid w:val='00664EF3'/><w:rPr><w:b/><w:b-cs/></w:rPr></w:style></w:styles></xsl:variable></xsl:stylesheet>
Using these two files , i am converting the xml file to word. Now what should i do if i want some of my paragraphs in the XML File to appear inside a Word specific Placeholder? When i say placeholder, i mean the "RICH TEXT", "TEXT", Active X controls which appear on the Developer tab of the Word Ribbon.
Please help me out..
Thanks
Teja
|
|
|
|
|
Don't you need to consult the WordML documentation for that?
|
|
|
|
|
Hey,
I did consult the Wordml for that and have come to know that these tags
<w:sdt showingplchdr="t" docpart="DefaultPlaceholder_22675703" xmlns:w="#unknown"><p><span><span style="color:gray">Click here to enter text.</span></span><w:sdtpr /></p></w:sdt>Address <w:control w:shapeid="_x0000_i1028" xmlns:w="#unknown" />
These tags helped me when i placed them in a HTML document and opened that html in word. Ofcourse i had to include the tag definitions in the HTML tag.
This process was successful. Now when i try placing these tags in an XSLT Which i wrote for my xml document, they are not appearing.
Could u please specify as to where shud i place these tags in my XSL Document
Thanks in advance
Teja
|
|
|
|
|
Tejabhiram wrote: Could u please specify as to where shud i place these tags in my XSL Document
I don't know what tags you are talking about. I you attempted to post XML on this forum you failed. Read the posting instructions.
If you do not know how to use XSLT there are good tutorials on www.w3schools.com
|
|
|
|
|
Hi there,
I'm trying to teach myself linq to xml and I've been struggling to implement a linq to xml class with which I can update values in a given xml file.
I'm a total beginner at this so I have probably made a simple mistake.
My Base class is as follows:
Public Class WebSite
Private _Id As String
Public Property Id() As String
Get
Return (_Id)
End Get
Set(ByVal value As String)
_Id = value
End Set
End Property
Private _Link As String
Public Property Link() As String
Get
Return (_Link)
End Get
Set(ByVal value As String)
_Link = value
End Set
End Property
Private _Picture As String
Public Property Picture() As String
Get
Return (_Picture)
End Get
Set(ByVal value As String)
_Picture = value
End Set
End Property
Private _ModifiedOn As String
Public Property ModifiedOn() As String
Get
Return (_ModifiedOn)
End Get
Set(ByVal value As String)
_ModifiedOn = value
End Set
End Property
Public Sub New(ByVal xElement As XElement)
Id = xElement.Attribute("Id").Value
Link = xElement.Element("Link").Value
Picture = xElement.Element("Picture").Value
ModifiedOn = xElement.Element("ModifiedOn").Value
End Sub
Private _xElement As XElement
Public Property xElement() As XElement
Get
Return New XElement("Website", New XAttribute("Id", Id), New XElement("Link", Link), New XElement("Picture", Picture), New XElement("ModifiedOn", ModifiedOn))
End Get
Set(ByVal value As XElement)
_xElement = value
End Set
End Property
The sub that I am trying to implement is as follows:
Public Class Portfolio
Inherits List(Of WebSite)
Public Sub UpdateWebsite(ByVal xmlFile As String, ByVal WebId As String, ByVal WebLink As String, ByVal WebPic As String, ByVal WebMod As String)
Dim doc As XDocument = XDocument.Load(xmlFile)
Dim query = From xElem In doc.Descendants("Website") _
Where xElem.@Id = WebId _
Select New WebSite(xElem)
With query.SingleOrDefault
.Id = WebId
.Link = WebLink
.Picture = WebPic
.ModifiedOn = WebMod
End With
Me.Clear()
AddRange(query)
Save(xmlFile)
End Sub
Public Sub Save(ByVal xmlFile As String)
Dim xml As New XElement("Portfolio", From p In Me _
Select p.xElement)
xml.Save(xmlFile)
End Sub
End Class
The Xml file I am trying to edit:
<?xml version="1.0" encoding="utf-8"?>
<Portfolio>
<Website Id="1">
<Link>Test Link</Link>
<Picture>Test Image</Picture>
<ModifiedOn>Test Date</ModifiedOn>
</Website>
</Portfolio>
I just can't seem to get the the class to update.
I hate getting stuck like this!
Any Ideas.
Many Thanks in advance.
JimBob SquarePants
*******************************************************************
"He took everything personally, including our royalties!"
David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager
*******************************************************************
|
|
|
|
|
|
My apologies,
I didn't quite know where to post it as the question covers both fields.
Still stuck though.
JimBob SquarePants
*******************************************************************
"He took everything personally, including our royalties!"
David St.Hubbins, Spinal Tap about Ian Faith, their ex-manager
*******************************************************************
|
|
|
|
|
Your question involves LINQ usage. Thus, you should post it under the .NET Framework forum. Since it is written in Visual Basic, you could have place it there as a second choice. However, you should still only post it in one forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Saturday, March 28, 2009 5:11 PM
|
|
|
|
|
I have successfully transformed one xml document into another xml document which is being saved using XMLTextWriter . Now I want to transform this transformed document into another xml document, while doing this I got exception saying "Document cannot have mutilple document elements"
|
|
|
|
|
The "one-and-only" document element is the root element of the document, and, thus, contains all the other elements. You must first create a document element to enclose your transformation output.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
modified on Tuesday, March 24, 2009 10:23 AM
|
|
|
|
|
I think you have more than one parent nodes in an xml file
i.e
<aa>..
<bb>..
it should be
<root>
|
|
|
|
|
The document element is the top most "parent" node. Also, your example code is not showing.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi all,
I have an object called “Report” that I want to serialize.
The saved object will be open at IE browser.
I want to save object from C# code with line at the head:
<?xml-stylesheet href="Report.xslt" type="text/xsl" ?>
How I do that?
I used with XmlSerializer from microsoft.
var serializer = new XmlSerializer(typeof(Report), NameSpace);
writer = new StreamWriter(fullpath));
serializer.Serialize(writer, this);
The result is :
<?xml version="1.0" encoding="utf-8" ?>
<Report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/Report.xsd">
<StartDateTimeTest>22-9-2009 12:00:12</StartDateTimeTest>
<EndDateTimeTest>22-9-2009 12:10:12</EndDateTimeTest> ......
And i want to get
<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet href="Report.xslt" type="text/xsl" ?>
<Report xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/Report.xsd">
<StartDateTimeTest>22-9-2009 12:00:12</StartDateTimeTest>
<EndDateTimeTest>22-9-2009 12:10:12</EndDateTimeTest>.....
I am very desperate,
Thanks all.
Ido
|
|
|
|