|
I think your XSL is fine. It's probably got something to do with how you're organizing the WordML tags. For instance, when I see the node <w:rPr> in a WordML, it's usually inside a <w:r> instead of a <w:pPr>. I would just be checking that the WordML is correct because your XSL looks fine and shouldn't be the cause of the changing fonts.
|
|
|
|
|
Hi everybody,
I reading an XML file with the code bellow and when I want to get the value of an xml node there are also whitespaces (space, newline, tab) and the Ignore Whitespace are set to true.
Any ideea is welcome.
Dim xmlsettings As New XmlReaderSettings
With xmlsettings
.ConformanceLevel = ConformanceLevel.Auto
.IgnoreComments = True
.IgnoreProcessingInstructions = True
.IgnoreWhitespace = True
End With
Dim reader As XmlReader = XmlReader.Create(file, xmlsettings)
Dim doc As New XmlDocument
doc.Load(reader)
Dim root As XmlElement = doc.DocumentElement
Dim invoiceId As XmlNode = root.SelectSingleNode("/a/b")
biglewy
|
|
|
|
|
They hide that information in the documentation[^]
Gets or sets a value indicating whether to ignore insignificant white space.
White space that is not considered to be significant includes spaces, tabs, and blank lines
used to set apart the markup for greater readability.
led mike
|
|
|
|
|
If the spaces inside a tag are significant, it's best to enclose them in a CDATA block so they will always be preserved, for example:
<foo><![CDATA[this is
lots of
stuff...
x>]]
</foo>
|
|
|
|
|
Thanks because you reply to this question.
I think I wasn't very clear.
So, my problem is that I have an xml node like below and I want to read this node without whitespace,in my code I create an XmlReaderSettings.IgnoreWhitespace=true,
but my problem is that when I read the node I got also the whitespaces(newline,tabs) that I don't want, even if is set the xmlsettings.ignorewhitespace=true.
I read the file wiht xmlreader and after then for further processing this reader it's given to an xmldocument like this:
Dim xmlsettings As New XmlReaderSettings
With xmlsettings
.IgnoreWhitespace = True
.IgnoreComments = True
.ProhibitDtd = False
End With
Dim reader As XmlReader = XmlReader.Create(file, xmlsettings)
Dim doc As New XmlDocument
doc.PreserveWhitespace = False
doc.Load(reader)
reader.Close()
Dim root As XmlElement = doc.DocumentElement
Dim invoiceId As XmlNode = _ root.SelectSingleNode("/invoice_collection/customer_info/customer_code")
Dim customer_code = invoiceId.InnerText
<invoice_collection>
<customer_info>
<customer_code>
0006034318
</customer_code>
</customer_info>
</invoice_collection>
biglewy
|
|
|
|
|
biglewy wrote: I got also the whitespaces(newline,tabs) that I don't want, even if is set the xmlsettings.ignorewhitespace=true.
yes because as my post and the MSDN documentation explains that property is ONLY FOR WHITESPACE IN THE MARKUP .
led mike wrote: White space that is not considered to be significant includes spaces, tabs, and blank lines
used to set apart the markup for greater readability.
led mike
|
|
|
|
|
Just change your code to trim off the leading and trailing spaces:
Dim customer_code = invoiceId.InnerText.Trim()
|
|
|
|
|
I want to define a schema for an XML fiel that contains either a "Topic" or a "TopicList" which is a collection of topics.
i.e. the XML file should contain either
<?xml blubber?>
<Topic>
<!-- Topic blubber -->
</Topic>
or
<?xml blubber?>
<TopicList>
<Topic>
<!-- Topic blubber for topic 1 -->
</Topic>
<Topic>
<!-- Topic blubber for topic 2 -->
</Topic>
</TopicList>
I currently make the topic list required, but I'm curious how to avoid that.
|
|
|
|
|
peterchen wrote: but I'm curious how to avoid that.
Why would you want to? It seems your current solution is correct.
led mike
|
|
|
|
|
It's more a general question: can I check against different "top level tags" with one Schema?
All use cases I can imagine a mandatory "outer tag" solves things. But I'm doing my first "serious toying" with XML, I still don't like all these tags*, I come from a "be strict with your output, but flexible on your input" culture, and I just want to KNOW
a client once wanted 500 point curves exported as <point><X>12.34</X><Y>123.42</Y></point> in a time critical high throughput application - bno problem making them happy, but I'm still a big XML sceptic.
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
It's much easier to always have the outer container tag, no matter how many tags are inside it. That way, you can enumerate all the Topics with a simple /TopicList/Topic XPath query. Don't take shortcuts on your schema just to save yourself 5 seconds of typing.
|
|
|
|
|
This is easy to do in the Schema, the software that uses it is where the complication comes in with this type of structure. Never understood why someone would want to do this, but it can be done.
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:complexType name="Topic">
</xs:complexType>
<xs:complexType name="TopicList">
<xs:sequence>
<xs:element type="Topic" minOccurs="0" maxOccurs="unbounded"></xs:element>
</xs:sequence>
</xs:complexType>
<xs:complexType name="RootNode">
<xs:choice>
<xs:element type="Topic"></xs:element>
<xs:element type="TopicList"></xs:element>
</xs:choice>
</xs:complexType>
<xs:element type="RootNode"></xs:element>
</xs:schema>
Your root node is of type "RootNode", which is a Choice , meaning it will accept either a "Topic" or a "TopicList". And "TopicList" is a sequence of "Topics".
|
|
|
|
|
thanks a lot for the reply!
BoneSoft wrote: the complication comes in with this type of structure. Never understood why someone would want to do this, but it can be done.
OK OK, I get the hints
We are a big screwed up dysfunctional psychotic happy family - some more screwed up, others more happy, but everybody's psychotic joint venture definition of CP
Linkify! || Fold With Us! || sighist
|
|
|
|
|
IMHO, if the concept of TopicList exists and the info meaningful, it should be represented explicitly.
We're the regulators that de-regulate
We're the animators that de-animate
Fold with us! ¤ flickr
|
|
|
|
|
This is my first attempt at making "real" modifications to an xsl stylesheet, and I'm completely stumped now. This is probably something simple, so try not to laugh too much.
Here's the code I'm having trouble with:
<xsl:variable name="reportName">
<xsl:value-of select="NodeName"/>
</xsl:variable>
<xsl:value-of select="$reportName"/>
<!--Does not work-->
<xsl:value-of select="//PageXML/Document/report[name = $reportName]/regionalFlag"/>
<!--Works fine-->
<xsl:value-of select="//PageXML/Document/report[name = 'workordertime']/regionalFlag"/>
Now, I'm printing the value of $reportName every time and it IS coming up as workordertime, but for some reason it isn't selecting any value. If I hardcode the report name, however, it DOES work... so the basic XSL is right. I'm fairly sure that's how I'd use a variable to do the select, as the same technique is used in other places... I have no idea what could be causing the problem...
|
|
|
|
|
Try using parameter instead of variable
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
Parameters are passed into the stylesheet though right? That won't help here, I'm running through a list of reports from the source sheet, and trying to find configuration information for each report also in the source sheet... so it's not something I can just pass in on the command line.
|
|
|
|
|
You define the parameter the same way as you devine the variable.
Just write: xsl:parameter.
I have no idea, if it is passed throught stylesheets. sorry
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
I get an error saying that xsl:parameter is an invalid child element when I try to use it.
|
|
|
|
|
Sorry, it is xsl:param , not xsl:parameter
Sincerely,
Elina
Life is great!!!
Enjoy every moment of it!
|
|
|
|
|
That gives me a syntax error too, which says the same basic thing only with fewer words.
|
|
|
|
|
This actually works just fine. Could you please elaborate on what "name" is? I assume it's a child element of report. There's nothing that I can see would be wrong with this code. Could you also please give some indication on what that non-working statement is returning in the output?
|
|
|
|
|
Yes, I'm pretty sure name is a child element of report. I'm not at work now though so I can't look. It SHOULD print out "true" when it gets to the workordertime report but I'm getting nothing at all. It prints out "true" fine when I hardcode 'workordertime' instead of using the $reportname variable though.
I can look at the source xml tomorrow and post it, I didn't have a chance to work on that today anyway.
|
|
|
|
|
One thing that I thought of is that there may be some whitespace in the variable that is not in your hard coded 'workordertime'. You might want to try this:
<xsl:variable name="reportName">
<xsl:value-of select="normalize-space(NodeName)"/>
</xsl:variable>
|
|
|
|
|
Normalize-space didn't work.
Here's the relevant part of the source XML:
<PageXML>
<Ident>14</Ident>
<PageIdent>266</PageIdent>
<Name>test</Name>
<Document>
<report>
<name>workordertime</name>
<regionalFlag>true</regionalFlag>
</report>
</Document>
</PageXML>
The whole document would be way too large to post...
|
|
|
|