• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

XSLT or XML Parse

New Here ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied



Hey all
I am getting all munged up no matter what i do. I was able to get XSLT to parse/format my data until i reached the "Section" area of the document, and then i got thrown by XSLT 2.0 seemingly refusing to do a regular expression.

Now i'm trying XMLParse and am absolutely not able to figure out where these data are.

I have 2 problems with XMLParse().
1) i was able to loop on toc_section but things quite simply blow up when i try to loop on toc_subsection. isDefined consistently throws 'must be a syntactically valid variable'. but if the variable doesn't exist i get ["giant name] is not defined in parsed_data" i solved toc_section ID by using try/catch, is there some other way? If not How would you design the try catch to get me the hrefs to the subsection id AND the subsection name. Sample code below:

<cftry>
<cfif len(parsed_data.report.chapter.chapter_content.toc.toc_section .XmlAttributes.id)><a href="###parsed_data.report.chapter.chapter_content.toc.toc_section.XmlAttributes.id#">#parsed_data.report.chapter.chapter_content.toc.toc_section .toc_head#</a>
</cfif>
<cfcatch>
#parsed_data.report.chapter.chapter_content.toc.toc_section
.toc_head#
</cfcatch>
</cftry>
<cfloop collection="#parsed_data.report.chapter.chapter_content.toc.toc_section .toc_subsection#" item="y">

</cfloop><!--- --->
</p>

2) even if i get through this part, i'm struck by noticing that the inline tags in the <body> tags (which really only need to become p_tags) are being pulled out of the xml text and presented outside of their context. Can you help with that (the one that's visible just needs to become an href to the figure that follows the first body. SPECIFIC XML BELOW

<Section ID="S_6_1">
<Section_Text>
<Body_Head>6.1 Overview</Body_Head>
<Body>A lighting upgrade is the second stage in the building upgrade process. The staged approach accounts for the interactions among all the energy flows in a building (<SeeFigure FigureID="F_6_1">Figure 6.1</SeeFigure>) and produces a systematic method for planning upgrades that maximize energy savings. When the staged approach is performed sequentially, each stage includes changes that will affect the upgrades performed in subsequent stages, thus setting the overall process up for the greatest energy and cost savings possible. In the staged approach to building upgrades, lighting upgrades come early in the process because the lighting system has a significant impact on other building systems, affecting heating and cooling loads and power quality.</Body>
<Figure FigureID="F_6_1">
<filename>EPA-BUM-Lighting_6-1.gif</filename>
<Figure_Title>Figure 6.1: The staged approach to building upgrades</Figure_Title>
<Figure_Caption>The staged approach to building upgrades accounts for the interactions among all the energy flows in a building. Each stage includes changes that will affect the upgrades performed in subsequent stages, thus setting the overall process up for the greatest energy and cost savings possible. Lighting upgrades come early in the process, because the lighting system affects heating and cooling loads and power quality.</Figure_Caption>
</Figure> ...

If anybody can make recommendations, i'd really appreciate it.

I'm unable to post images, i think....so am including a link to the
parsed xml image

I'm happy to read documents about how best to do this, but all i am finding is one level deep (in it's loops) or is taken from the multi level and put into the single level...
TOPICS
Advanced techniques

Views

465

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

Can you give me a simple example of what you are trying to do with this
data. I do a lot of XML/XSLT with ColdFusion. But I was unclear from
your code what you where trying to accomplish.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

the xml file in and of itself represents a chapter in a book. It has a table of contents and that is where problem 1 is occuring. It also has a series of sections, which is where problem 2 is expected to occur. The sections correlate to the TOC and the TOC is generated with links to the section and subsections Using a name and a href.

Were you able to view the image?

The end result is HTML,
I've gotten a little farther in the Table of Contents and may be able to handle it using another try catch but why doesn't isDefined() return something other than a big fat error? And is there another option for xml only? something like 'node exists'?

For the body i simply haven't reached it yet, but if you look at the xml sample you'll see that there are tags inline with the text. I need what i do with those tags to STAY inline with the text. I'd be fine to use CFML: replace(), it'd be darned easy, but i'm not sure how to get the unparsed xml out of the parsed xml.

i'm using class codes to markup the text so really all i need to do is change the <body></body> to <p class="whatever"></p> and the <figure> to <img>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

Yes, I was able to see the dump image. Can you send me a fragment of
the XML? I could play with it a bit. Feel free to send it to me
directly: ian[dot]skinner[at]bloodsource[dot]org

You definitely should not need to be using <cftry><cfcatch> logic like
you are. And I am sure there is considerable overhead with doing so.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 15, 2007 Feb 15, 2007

Copy link to clipboard

Copied

LATEST
Miki

I just wanted to post here to make sure you have received the code I
sent to you. I didn't want it to end up in some kind of anti-spam black
hole.

If you did receive it great. I hope it was informative. If not, let me
know and I'll try to re-send it if you like.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

Use the associative-array or bracket notation. You could do something along the lines of

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 14, 2007 Feb 14, 2007

Copy link to clipboard

Copied

documents about how best to do this

Livedocs

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation